# 寒假打卡(2.08)

//1071 小赌怡情
#include<iostream>
using namespace std;
#include<vector>
#include<string>
int main() {
vector<string> ve;
int t, k;
cin >> t >> k;
int n1, b, t1, n2;
for (int i = 0; i < k; i++) {
cin >> n1 >> b >> t1 >> n2;
if (t1 > t) {
string a = "Not enough tokens.  Total = " + to_string(t) + ".";
ve.push_back(a);
}
else if (n1 > n2 && b == 0) {
t += t1;
string a = "Win " + to_string(t1) + "!  Total = " + to_string(t) + ".";
ve.push_back(a);

}
else if (n1 < n2 && b == 1) {
t += t1;
string a = "Win " + to_string(t1) + "!  Total = " + to_string(t) + ".";
ve.push_back(a);
}
else {
t -= t1;
string a = "Lose " + to_string(t1) + ".  Total = " + to_string(t) + ".";
ve.push_back(a);
}
if (t == 0) {
string a = "Game Over.";
ve.push_back(a);
}
}
for (int i = 0; i < ve.size(); i++) {
cout << ve[i];
if (ve[i] == "Game Over.") {
break;
}
else {
cout << endl;
}
}
}
//1072 开学寄语
#include<iostream>
using namespace std;
#include<vector>
#include<set>
struct stu {
string name;
vector<int> wei;
}stus;
int main() {
vector<stu> vestu;
int n, m;
cin >> n >> m;
int wei;
set<int> sewei;
for (int i = 0; i < m; i++) {
cin >> wei;
sewei.insert(wei);
}
string name;
int shu;
int wu;
int sum = 0;
for (int i = 0; i < n; i++) {
cin >> name >> shu;
vector<int> vewei;
for (int j = 0; j < shu; j++) {
cin >> wu;
if (sewei.find(wu) != sewei.end()) {
vewei.push_back(wu);
sum++;
}
}
if (vewei.size() != 0) {
stus.name = name;
stus.wei = vewei;
vestu.push_back(stus);
}
}
for (auto j : vestu) {
cout << j.name << ": ";
for (int i = 0; i < j.wei.size(); i++) {
printf("%04d", j.wei[i]);
if (i == j.wei.size() - 1) {
cout << endl;
}
else {
cout << ' ';
}
}
}
cout << vestu.size() << ' ' << sum;
}

...全文
47 回复 打赏 收藏 转发到动态 举报

264

c++javapython 技术论坛（原bbs） 广东省·深圳市

• 近7日
• 近30日
• 至今