2 a+b?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
#include <string.h>

int a[1000005], b[1000005], ans[1000005];
char s[1000005], t[1000005];

int max(int a, int b) { return a > b ? a : b; }

int main() {
scanf("%s", s);
scanf("%s", t);
int len1 = strlen(s), len2 = strlen(t);
for (int i = len1 - 1, j = 0; i >= 0; i--, j++) {
a[j] = s[i] - '0';
}
for (int i = len2 - 1, j = 0; i >= 0; i--, j++) {
b[j] = t[i] - '0';
}
int len = max(len1, len2) + 1;
for (int i = 0; i < len; i++) {
ans[i] += a[i] + b[i];
ans[i + 1] += ans[i] / 10;
ans[i] %= 10;
}
while (ans[len] == 0)
len--;
for (int i = len; i >= 0; i--)
printf("%d", ans[i]);
}

3 加训

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <stdio.h>

int main() {
int n, m;
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; i++) {
if (i % m == 0)
printf("jiashui\n");
else
printf("jiaxun\n");
}
return 0;
}

4 Tanphoon大战Joker

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>

int main() {
int T;
scanf("%d", &T);
while (T--) {
int n;
scanf("%d", &n);
if (n % 3 == 0)
printf("Joker\n");
else
printf("Tanphoon\n");
}
}

5 好吃的学长

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int a[1000005];
for (int i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
long long s = 0;
for (int i = 0; i < m; i++)
s += a[i];
cout << s << '\n';
}

6 数字游戏

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>

int a[200010], len = 0;
int main() {
long long n;
scanf("%lld", &n);
while (n) {
a[len++] = n % 7;
n /= 7;
}
for (int i = len - 1; i >= 0; i--)
printf("%d", a[i]);
printf("\n");
}