陌陌的pat乙级题解
题解
过程模拟 |
ans表示此次比赛的结果 |
n1 > n2 ans = 0, 否则ans = 1 |
这样直接去和b比较,如果相等就OK |
每次输赢都改变N |
Code
#include <iostream>using namespace std;
int main()
{int N, M;scanf("%d%d", &N, &M);while (M--){int n1, n2;int x, y;cin >> n1 >> x >> y >> n2;int ans = n1 > n2 ? 0 : 1;if (N == 0){printf("Game Over.");break;}if (y > N){printf("Not enough tokens. Total = %d.", N);}else if (x == ans){N += y;printf("Win %d! Total = %d.", y, N);}else if (x != ans){N -= y;printf("Lose %d. Total = %d.", y, N);}printf("\n");}return 0;
}