题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/994805264312549376
题解:
1 #include<iostream> 2 using namespace std; 3 4 int main() { 5 int T, K, n1, b, t, n2; 6 cin >> T >> K; 7 while (K--) { 8 cin >> n1 >> b >> t >> n2; 9 if (T == 0) { 10 cout << "Game Over." << endl; 11 break; 12 } 13 if (t > T) cout << "Not enough tokens. Total = " << T << "." << endl; 14 else { 15 if (b == 0 && n2<n1 || b == 1 && n2>n1) { 16 T += t; 17 cout << "Win " << t << "! Total = " << T << "." << endl; 18 } 19 else { 20 T -= t; 21 cout << "Lose " << t << ". Total = " << T << "." << endl; 22 } 23 } 24 } 25 return 0; 26 }
原文地址:https://www.cnblogs.com/Gzu_zb/p/10011064.html
时间: 2024-10-17 14:13:25