# PAT Basic 1071. 小赌怡情(15)

+关注继续查看

## 题目内容

n1 b t n2

100 4
8 0 100 2
3 1 50 1
5 1 200 6
7 0 200 8

Win 100! Total = 200.
Lose 50. Total = 150.
Not enough tokens. Total = 150.
Not enough tokens. Total = 150.

100 4
8 0 100 2
3 1 200 1
5 1 200 6
7 0 200 8

Win 100! Total = 200.
Lose 200. Total = 0.
Game Over.

## 简评

1.“输出格式”中的两句话之间的空格数，和“输出样例”中不一样。后者是2个。题目提交需要按照2个空格来。
2."Game Over."这句话目测是不在测试用例中的。输出"Game Over."后，是否输出换行符，都不影响评测结果。

## AC代码

#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <set>
#include <iomanip>
#include <sstream>
#include <unordered_map>

using namespace std;

int main() {
int T, K;
cin >> T >> K;
int n1, b, t, n2;
for (int i = 0; i < K; i++) {
cin >> n1 >> b >> t >> n2;

if (t > T) {
printf("Not enough tokens.  Total = %d.\n", T);
}else if((b == 0 && n2 < n1) || (b == 1 && n2 > n1)) {
T += t;
printf("Win %d!  Total = %d.\n", t, T);
}
else {
T -= t;
printf("Lose %d.  Total = %d.\n", t, T);
}
if (T == 0) {
printf("Game Over.\n");
return 0;
}
}

return 0;
}

|
9月前
Basic Auth认证
Basic Auth认证
85 1
|

nodejs.ER_NOT_SUPPORTED_AUTH_MODEError: ER_NOT_SUPPORTED_AUTH_MODE:
nodejs.ER_NOT_SUPPORTED_AUTH_MODEError: ER_NOT_SUPPORTED_AUTH_MODE:
77 0
|

PAT (Basic Level) Practice （中文）第1002题
PAT (Basic Level) Practice （中文）第1002题
64 0
|
Go
Basic introduction about SAP SPS (Support Package Stack)
You can get the detailed definition here https://websmp207.sap-ag.de/~sapidb/011000358700003734172003E/
92 0
|
Web App开发 Java

101 0
|

BASIC College，或许就是每个技术人的“伊甸园”
BASIC College是蚂蚁金服内部的一所神秘的“大学”。
1382 0
|

SQLNonTransientConnectionException: CLIENT_PLUGIN_AUTH is required

8803 0
|
Java API
Access restriction: The type 'BASE64Decoder' is not API (restriction on required library xxx)

2739 0