L1-011 A-B (20 分)——18分
https://pintia.cn/problem-sets/994805046380707840/problems/994805130426171392
#include <algorithm>
#include <cstring>
#include <iostream>
#include <set>
using namespace std;
set<char> s;
string a, b;
int main() {
getline(cin, a);
getline(cin, b);
for (int i = 0; i < b.size(); i++) s.insert(b[i]);
for (int i = 0; i < a.size(); i++)
if (!s.count(a[i])) cout << a[i];
cout << endl;
return 0;
}
L1-012 计算指数 (5 分)
#include <algorithm>
#include <cstring>
#include <iostream>
#include <cmath>
using namespace std;
int n;
int main()
{
cin >> n;
cout << "2^" << n << " = " << (int)pow(2,n) << endl;
return 0;
}
L1-013 计算阶乘和 (10 分)
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;
int n;
int cal(int a) {
int sum = 1;
for (int i = 1; i <= a; i++) sum *= i;
return sum;
}
int main() {
cin >> n;
int res = 0;
for (int i = 1; i <= n; i++) res += cal(i);
cout << res << endl;
return 0;
}
L1-014 简单题 (5 分)
#include <iostream>
using namespace std;
int main() {
cout << "This is a simple problem." << endl;
return 0;
}
L1-015 跟奥巴马一起画方块 (15 分)
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;
int n;
char c;
int main() {
cin >> n >> c;
for (int i = 0; i < (n + 1) / 2; i++) {
for (int j = 0; j < n; j++) {
cout << c;
}
cout << endl;
}
return 0;
}
L1-016 查验身份证 (15 分)
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;
int k[] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
char s[] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
int n;
bool flag = true;
int main() {
cin >> n;
while (n--) {
string id;
cin >> id;
int sum = 0;
for (int i = 0; i < 17; i++) sum += (id[i] - '0') * k[i];
if (id[17] != s[sum % 11]) {
cout << id << endl;
flag = false;
}
}
if (flag) cout << "All passed" << endl;
return 0;
}
L1-017 到底有多二 (15 分)
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;
string n;
float f = 1, o = 1;
int cnt;
int main() {
cin >> n;
if (n[0] == '-') {
n = n.substr(1);
f = 1.5;
}
if ((n[n.size() - 1] - '0') % 2 == 0) o = 2;
for (int i = 0; i < n.size(); i++)
if (n[i] == '2') cnt++;
printf("%.2f%%", 100 * (float)cnt / n.size() * f * o);
return 0;
}
L1-018 大笨钟 (10 分)
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;
int h, m;
int main() {
scanf("%d:%d", &h, &m);
if (h >= 0 && h <= 12) {
printf("Only %02d:%02d. Too early to Dang.", h, m);
} else {
if (m == 0) {
for (int i = 0; i < h - 12; i++) cout << "Dang";
} else {
for (int i = 0; i <= h - 12; i++) cout << "Dang";
}
cout << endl;
}
return 0;
}
L1-019 谁先倒 (15 分)
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;
int ca, cb;
int ba, bb;
int n;
int main() {
cin >> ca >> cb;
ba = ca, bb = cb;
cin >> n;
for (int i = 0; i < n; i++) {
int flag = 1;
int a, b, c, d;
// 甲喊 甲划 乙喊 乙划
cin >> a >> b >> c >> d;
// 如果谁比划出的数字正好等于两人喊出的数字之和
if (b == a + c) flag *= -1;
if (d == a + c) flag *= -1;
if (flag != 1) {
if (b == a + c) --ca;
if (d == a + c) --cb;
if (ca < 0) {
cout << 'A' << endl << bb - cb << endl;
break;
}
if (cb < 0) {
cout << 'B' << endl << ba - ca << endl;
break;
}
}
}
return 0;
}
L1-020 帅到没朋友 (20 分)——10分
https://pintia.cn/problem-sets/994805046380707840/problems/994805117167976448
#include <algorithm>
#include <cstring>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
int n, k;
set<int> s, q;
vector<int> v;
bool flag;
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &k);
for (int i = 0; i < k; i++) {
int tmp;
scanf("%d", &tmp);
s.insert(tmp);
}
}
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &k);
if (!q.count(k) && !s.count(k)) {
flag = true;
v.push_back(k);
q.insert(k);
}
}
if (!flag)
printf("No one is handsome\n");
else {
for (int i = 0; i < v.size(); i++) {
printf("%d", v[i]);
if (i != v.size() - 1) printf(" ");
}
puts("");
}
return 0;
}
## 二级标题