同时附上AC代码
第一题 新世界
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include<iostream> #include<cstring> #include<algorithm> #include<cstdio> using namespace std; int d, m, w; int i, j, k; typedef long long ll; int main() { scanf("%d%d%d", &d, &m, &w); scanf("%d%d%d", &i, &j, &k); ll y = m * d; ll total = (k - 1) * y + (j - 1) * d + i; ll res = (total - 1) % w; printf("%c\n", 'a' + res); return 0; } |
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 30 31 32 33 34 35 36 37 38 39 | #include<iostream> #include<algorithm> #include<cstdio> #include<cstring> using namespace std; const int N = 10010; int p[N]; int n; int a, b, c, t; int find(int x) { if (x != p[x]) p[x] = find(p[x]); return p[x]; } int main() { scanf("%d", &n); for (int i = 0; i < N; i++) p[i] = i; while (n--) { scanf("%d", &t); if (t == 1) { scanf("%d%d", &a, &b); int pa = find(p[a]); int pb = find(p[b]); if (pa != pb) p[pa] = pb; } else { scanf("%d%d%d", &a, &b, &c); a = a % c; b = b % c; if (find(p[a]) == find(p[b])) puts("YES"); else puts("NO"); } } } |
全部评论
(0) 回帖