题目:https://pintia.cn/problem-sets/994805260223102976/problems/994805264312549376

代码

  1. #include<cstdio>
  2. int main(){
  3. int T, K;
  4. int n1, b, t, n2;
  5. scanf("%d%d", &T, &K);
  6. int x = T;
  7. for(int i = 0; i < K; i++){
  8. scanf("%d%d%d%d", &n1, &b, &t, &n2);
  9. if (x == 0){
  10. printf("Game Over.\n");
  11. break;
  12. }
  13. else if(x < t){
  14. printf("Not enough tokens. Total = %d.\n", x);
  15. continue;
  16. }
  17. if(b == 0) b = -1;
  18. if(b * (n2 - n1) > 0){
  19. x += t;
  20. printf("Win %d! Total = %d.\n", t, x);
  21. } else {
  22. x -= t;
  23. printf("Lose %d. Total = %d.\n", t, x);
  24. }
  25. }
  26. }