PTA | 程序设计类实验辅助教学平台
两种方法差不多
#include <iostream>
using namespace std;
int main() {
int A, B, N, a1, a2, b1, b2;
cin >> A >> B >> N; //甲乙酒量
int a = A, b = B; //a和b用来记录A与B何时倒
while (N--) {
cin >> a1 >> a2 >> b1 >> b2;//甲喊 甲划 乙喊 乙划
if ((a2 == a1 + b1) && (a2 != b2)) //A输掉一轮
a--;
if ((b2 == a1 + b1) && (a2 != b2)) //B输掉一轮
b--;
if (a < 0) { //A倒下
cout << "A" << endl << B - b;
break;
}
if (b < 0) { //B倒下
cout << "B" << endl << A - a;
break;
}
}
return 0;
}
#include <iostream>
using namespace std;
int main() {
int A, B, n, a = 0, b = 0, a1, a2, b1, b2;
cin >> A >> B >> n;
while (n--) {
cin >> a1 >> a2 >> b1 >> b2;
if (a2 == a1 + b1 && b2 != a1 + b1)
a++;
if (b2 == a1 + b1 && a2 != a1 + b1)
b++;
if (a > A) {
cout << 'A' << endl << b << endl;
break;
}
if (b > B) {
cout << 'B' << endl << a << endl;
break;
}
}
return 0;
}
|