buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
#include <stdio.h> #define MAX 1000 int main(void) { int value[6] = {1, 5, 10, 50, 100, 500}; int c1 = 0; int c5 = 0; int c10 = 0; int c50 = 0; int c100 = 0; int c500 = 0; int c1000 = 0; int sum = 0; // printf("1??????5??????10??????50??????100??????500???????????????????????????????????\????????????????????????"); scanf("%d%d%d%d%d%d", &c1, &c5, &c10, &c50, &c100, &c500); sum = ((value[0] * c1) + (value[1] * c5) + (value[2] * c10) + (value[3] * c50) + (value[4] * c100) + (value[5] * c500)); if (sum > MAX) { c1000 = 1; } printf("%d", c1000); // printf("1000??????????????§????????´??????1?????§???????????´??????0??§??¨??????????????????", // c1000); return 0; }
#include <stdio.h> #define MAX 1000 int main(void) { int value[6] = {1, 5, 10, 50, 100, 500}; int c1 = 0; int c5 = 0; int c10 = 0; int c50 = 0; int c100 = 0; int c500 = 0; int c1000 = 0; int sum = 0; // printf("1??????5??????10??????50??????100??????500???????????????????????????????????\????????????????????????"); scanf("%d%d%d%d%d%d", &c1, &c5, &c10, &c50, &c100, &c500); sum = ((value[0] * c1) + (value[1] * c5) + (value[2] * c10) + (value[3] * c50) + (value[4] * c100) + (value[5] * c500)); if (sum >= MAX) { c1000 = 1; } printf("%d\n", c1000); // printf("1000??????????????§????????´??????1?????§???????????´??????0??§??¨??????????????????", // c1000); return 0; }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
182
3
#include <stdio.h> int main() { int c1, c5, c10, c50, c100, c500, all; scanf("%d %d %d %d %d %d", &c1, &c5, &c10, &c50, &c100, &c500); all = c1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500; if (all >= 1000) { printf(1); } else { printf(0); } return 0; }
#include <stdio.h> int main() { int c1, c5, c10, c50, c100, c500, all; scanf("%d %d %d %d %d %d", &c1, &c5, &c10, &c50, &c100, &c500); all = c1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500; if (all >= 1000) { printf("1\n"); } else { printf("0\n"); } return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
96
6
#include <stdio.h> int main(void) { int c1, c5, c10, c50, c100, c500, i, a, b, c, d, e, f; i = 0; scanf("%d %d %d %d %d %d", &c1, &c5, &c10, &c50, &c100, &c500); a = c1 * 1; b = c5 * 5; c = c10 * 10; d = c50 * 50; e = c100 * 100; f = c500 * 500; i = a + b + c + d + e + f; if (i > 1000) { printf("1\n"); } else { printf("0\n"); } return 0; }
#include <stdio.h> int main(void) { int c1, c5, c10, c50, c100, c500, i, a, b, c, d, e, f; i = 0; scanf("%d %d %d %d %d %d", &c1, &c5, &c10, &c50, &c100, &c500); a = c1 * 1; b = c5 * 5; c = c10 * 10; d = c50 * 50; e = c100 * 100; f = c500 * 500; i = a + b + c + d + e + f; if (i >= 1000) { printf("1\n"); } else { printf("0\n"); } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
145
2
#include <stdio.h> int main(void) { int a, b, c, d, e, f; scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f); a += b * 5 + c * 10 + d * 50 + e * 100 + f * 500; if (a > 1000) printf("1\n"); else printf("0\n"); }
#include <stdio.h> int main(void) { int a, b, c, d, e, f; scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f); a += b * 5 + c * 10 + d * 50 + e * 100 + f * 500; if (a >= 1000) printf("1\n"); else printf("0\n"); }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
92
2
#include <stdio.h> int main(void) { int a, b, c, d, e, f, s; scanf("%d %d %d %d %d", &a, &b, &c, &d, &e, &f); s = a * 1 + b * 5 + c * 10 + d * 50 + e * 100 + f * 500; if (1000 <= s) { printf("1\n"); } else { printf("0\n"); } return 0; }
#include <stdio.h> int main(void) { int a, b, c, d, e, f, s; scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f); s = a * 1 + b * 5 + c * 10 + d * 50 + e * 100 + f * 500; if (1000 <= s) { printf("1\n"); } else { printf("0\n"); } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
105
2
#include <iostream> int main() { int a, b, c, d, e, f; std::cin >> a >> b >> c >> d >> e >> f; if (a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500 > 1000) std::cout << 1 << std::endl; else std::cout << 0 << std::endl; return 0; }
#include <iostream> int main() { int a, b, c, d, e, f; std::cin >> a >> b >> c >> d >> e >> f; if (a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500 >= 1000) std::cout << 1 << std::endl; else std::cout << 0 << std::endl; return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
87
2
#include <iostream> int main() { int a, b, c, d, e, f, g; std::cin >> a >> b >> c >> d >> e >> f; g = a * 1 + b * 5 + c * 10 + d * 50 + e * 100 + f * 500; if (g < 1000) { std::cout << 0 << std::endl; } if (g > 1000) { std::cout << 1 << std::endl; } else if (g = 1000) { std::cout << 1 << std::endl; } }
#include <iostream> int main() { int a, b, c, d, e, f, g; std::cin >> a >> b >> c >> d >> e >> f; g = a * 1 + b * 5 + c * 10 + d * 50 + e * 100 + f * 500; if (g < 1000) { std::cout << 0 << std::endl; } else if (g > 1000) { std::cout << 1 << std::endl; } else if (g = 1000) { std::cout << 1 << std::endl; } }
[["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95]]
1
120
1
#include <iostream> int main() { int a, b, c, d, e, f; std::cin >> a >> b >> c >> d >> e >> f; if (a + 5 * b + 10 * c + 50 * d + 100 * e + 500 * f > +1000) { std::cout << 1 << std::endl; } else { std::cout << 0 << std::endl; } return 0; }
#include <iostream> int main() { int a, b, c, d, e, f; std::cin >> a >> b >> c >> d >> e >> f; if (a + 5 * b + 10 * c + 50 * d + 100 * e + 500 * f >= 1000) { std::cout << 1 << std::endl; } else { std::cout << 0 << std::endl; } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
91
4
#include <stdio.h> int main(void) { int m, n; m = 0; scanf("%d", &n); m += n * 1; scanf("%d", &n); m += n * 5; scanf("%d", &n); m += n * 10; scanf("%d", &n); m += n * 50; scanf("%d", &n); m += n * 100; scanf("%d", &n); m += n * 500; printf("%d\n", m > 1000 ? 1 : 0); }
#include <stdio.h> int main(void) { int m, n; m = 0; scanf("%d", &n); m += n * 1; scanf("%d", &n); m += n * 5; scanf("%d", &n); m += n * 10; scanf("%d", &n); m += n * 50; scanf("%d", &n); m += n * 100; scanf("%d", &n); m += n * 500; printf("%d\n", m >= 1000 ? 1 : 0); }
[["-", 0, 2, 3, 4, 0, 41, 15, 16, 17, 47], ["+", 0, 2, 3, 4, 0, 41, 15, 16, 17, 20]]
1
130
2
#include <stdio.h> int main(void) { int a, b, c, d, e, f; int g, h, i, j, k, n; int ans; scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f); g = a * 1; h = b * 5; i = c * 10; j = d * 50; k = e * 100; n = f * 500; ans = g + h + i + j + k + n; if (ans > 1000) { ans = 1; } else { ans = 0; } printf("%d\n", ans); return 0; }
#include <stdio.h> int main(void) { int a, b, c, d, e, f; int g, h, i, j, k, n; int ans; scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f); g = a * 1; h = b * 5; i = c * 10; j = d * 50; k = e * 100; n = f * 500; ans = g + h + i + j + k + n; if (ans >= 1000) { ans = 1; } else { ans = 0; } printf("%d\n", ans); return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
145
2
#include <cstdio> int main() { int a[5]; scanf("%d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]); int sum = a[0] * 1 + a[1] * 5 + a[2] * 10 + a[3] * 50 + a[4] * 100 + a[5] * 500; if (sum % 1000 > 0) printf("1\n"); else printf("0\n"); return 0; }
#include <cstdio> int main() { int a[5]; scanf("%d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]); int sum = a[0] * 1 + a[1] * 5 + a[2] * 10 + a[3] * 50 + a[4] * 100 + a[5] * 500; if (sum >= 1000) printf("1\n"); else printf("0\n"); return 0; }
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
130
4
#include <cstdio> using namespace std; int main(void) { int a, b, c, d, e, f; scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f); int sum = 0; sum += a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500; if (sum >= 5000) { puts("1"); } else { puts("0"); } }
#include <cstdio> using namespace std; int main(void) { int a, b, c, d, e, f; scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f); int sum = 0; sum += a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500; if (sum >= 1000) { puts("1"); } else { puts("0"); } }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
105
2
#include <iostream> using namespace std; int a, b, c, d, e, f, g; int main() { cin >> a >> b >> c >> d >> e >> f; g = a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500; if (g >= 1000) { cout << '1' << endl; } else { cout << ' ' << endl; } return 0; }
#include <iostream> using namespace std; int a, b, c, d, e, f, g; int main() { cin >> a >> b >> c >> d >> e >> f; g = a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500; if (g >= 1000) { cout << '1' << endl; } else { cout << '0' << endl; } return 0; }
[["-", 0, 1, 0, 16, 31, 16, 12, 103, 0, 125], ["+", 0, 1, 0, 16, 31, 16, 12, 103, 0, 125]]
1
95
2
#include <bits/stdc++.h> using namespace std; int main() { int c, c5, c10, c50, c100, c500; cin >> c >> c5 >> c10 >> c50 >> c100 >> c500; if (c + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500 <= 1000) { cout << 0 << endl; } else { cout << 1 << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int c, c5, c10, c50, c100, c500; cin >> c >> c5 >> c10 >> c50 >> c100 >> c500; if (c + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500 < 1000) { cout << 0 << endl; } else { cout << 1 << endl; } }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
82
2
#include <iostream> using namespace std; int main() { int a, b, c, d, e, f, y; cin >> a >> b >> c >> d >> e >> f; y = (a * 1) + (b * 5) + (c * 10) + (d * 50) + (e * 100) + (d * 500); if (y >= 1000) { cout << 1 << endl; } else cout << 0 << endl; }
#include <iostream> using namespace std; int main() { int a, b, c, d, e, f, y; cin >> a >> b >> c >> d >> e >> f; y = (a * 1) + (b * 5) + (c * 10) + (d * 50) + (e * 100) + (f * 500); if (y >= 1000) { cout << 1 << endl; } else cout << 0 << endl; }
[["-", 0, 11, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 31, 22]]
1
100
2
#include <iostream> using namespace std; int main() { int a, b, c, d, e, f, g, h, i, j, k, l; cin >> a >> b >> c >> d >> e >> f; g = a; h = 5 * g; i = 10 * c; j = 50 * d; k = 100 * e; l = 500 * f; if (1000 <= g + h + i + j + k + l) cout << "1" << endl; else cout << "0" << endl; }
#include <iostream> using namespace std; int main() { int a, b, c, d, e, f, g, h, i, j, k, l; cin >> a >> b >> c >> d >> e >> f; g = a; h = 5 * b; i = 10 * c; j = 50 * d; k = 100 * e; l = 500 * f; if (1000 <= g + h + i + j + k + l) cout << "1" << endl; else cout << "0" << endl; }
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
118
2
#include <iostream> using namespace std; int main() { unsigned c, c1, c5, c10, c50, c100, c500; cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500; c = c1 * 1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500; cout << (c > 1000) << endl; return 0; }
#include <iostream> using namespace std; int main() { unsigned c, c1, c5, c10, c50, c100, c500; cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500; c = c1 * 1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500; cout << (c >= 1000) << endl; return 0; }
[["-", 0, 16, 31, 16, 12, 23, 0, 16, 17, 47], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 17, 20]]
1
80
2
#include <iostream> using namespace std; int main() { int c1, c5, c10, c50, c100, c500; cin >> c1 >> c10 >> c50 >> c100 >> c500; if ((((c1 * 1) + (c5 * 5) + (c10 * 10) + (c50 * 50) + (c100 * 100) + (c500 * 500)) / 1000) >= 1) { cout << 1 << endl; } else { cout << 0 << endl; } return 0; }
#include <iostream> using namespace std; int main() { int c1, c5, c10, c50, c100, c500; cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500; if ((((c1 * 1) + (c5 * 5) + (c10 * 10) + (c50 * 50) + (c100 * 100) + (c500 * 500)) / 1000) >= 1) { cout << 1 << endl; } else { cout << 0 << endl; } return 0; }
[["+", 31, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 17, 152]]
1
103
2
#include <iostream> using namespace std; int main() { int c1, c5, c10, c50, c100, c500; cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500; int g; g = c1 + 5 * c5 + 10 * c10 + 50 * c50 + 100 * c100 + 500 * c500; if (g > 1000) cout << 1 << endl; else cout << 0 << endl; return 0; }
#include <iostream> using namespace std; int main() { int c1, c5, c10, c50, c100, c500; cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500; int g; g = c1 + 5 * c5 + 10 * c10 + 50 * c50 + 100 * c100 + 500 * c500; if (g >= 1000) cout << 1 << endl; else cout << 0 << endl; return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
88
2
#include <iostream> using namespace std; int main() { int c[] = {1, 5, 10, 50, 100, 500}; int n = 0, m; for (int i = 0; i < 6; i++) { cin >> m; n = m * c[i]; } if (n >= 1000) { cout << 1 << endl; return 0; } cout << 0 << endl; return 0; }
#include <iostream> using namespace std; int main() { int c[] = {1, 5, 10, 50, 100, 500}; int n = 0, m; for (int i = 0; i < 6; ++i) { cin >> m; n += m * c[i]; if (n >= 1000) { cout << 1 << endl; return 0; } } cout << 0 << endl; return 0; }
[["-", 0, 14, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 7, 26, 27, 28, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["-", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
93
6
#include <iostream> using namespace std; int main() { int c1, c5, c10, c50, c100, c500, kanesum; cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500; kanesum = 1 * c1 + 5 * c5 + 10 * c10 + c50 * 50 * c100 * 100 + c500 * 500; if (kanesum >= 1000) { cout << 1 << endl; } else if (kanesum < 1000) { cout << 0 << endl; } }
#include <iostream> using namespace std; int main() { int c1, c5, c10, c50, c100, c500, kanesum; cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500; kanesum = 1 * c1 + 5 * c5 + 10 * c10 + c50 * 50 + c100 * 100 + c500 * 500; if (kanesum >= 1000) { cout << 1 << endl; } else if (kanesum < 1000) { cout << 0 << endl; } return 0; }
[["-", 12, 16, 31, 16, 12, 16, 31, 16, 17, 48], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 72], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 35]]
1
96
5
#include <stdio.h> int main(void) { int a, s, d, f, g, h, j; h = 0; scanf("%d %d %d %d %d %d", &a, &s, &d, &f, &g, &j); h = (a * 1) + (s * 5) + (d * 10) + (f * 50) + (g * 100) + (j * 500); if (1000 >= h) { printf("1\n"); } else { printf("0\n"); } return 0; }
#include <stdio.h> int main(void) { int a, s, d, f, g, h, j; h = 0; scanf("%d %d %d %d %d %d", &a, &s, &d, &f, &g, &j); h = (a * 1) + (s * 5) + (d * 10) + (f * 50) + (g * 100) + (j * 500); if (1000 <= h) { printf("1\n"); } else { printf("0\n"); } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
121
2
#include <stdio.h> int main(void) { int c1, c5, c10, c50, c100, c500, sum; scanf("%d %d %d %d %d %d", &c1, &c5, &c10, &c50, &c100, &c500); sum = c1 * 1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500; if (1000 < sum) { printf("1\n"); } else { printf("0\n"); } return 0; }
#include <stdio.h> int main(void) { int c1, c5, c10, c50, c100, c500, sum; scanf("%d %d %d %d %d %d", &c1, &c5, &c10, &c50, &c100, &c500); sum = c1 * 1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500; if (sum >= 1000) { printf("1\n"); } else { printf("0\n"); } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
105
4
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, e, f, total = 0; cin >> a >> b >> c >> d >> e >> f; total += a * 1 + b * 5 + c * 10 + d * 50 + e * 100 + d * 500; if (total >= 1000) cout << 1 << endl; else cout << 0 << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, e, f, total = 0; cin >> a >> b >> c >> d >> e >> f; total += a * 1 + b * 5 + c * 10 + d * 50 + e * 100 + f * 500; if (total >= 1000) cout << 1 << endl; else cout << 0 << endl; }
[["-", 0, 1, 0, 11, 12, 16, 12, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 16, 31, 22]]
1
88
2
#include <stdio.h> int main(void) { int c, d[6] = {1, 5, 10, 50, 100, 500}, i, ans = 0; for (i = 0; i < 6; ++i) { scanf("%d", &c); ans += c * d[i]; } if (ans >= 1000) printf("0\n"); else printf("1\n"); return 0; }
#include <stdio.h> int main(void) { int c, d[6] = {1, 5, 10, 50, 100, 500}, i, ans = 0; for (i = 0; i < 6; ++i) { scanf("%d", &c); ans += c * d[i]; } if (ans >= 1000) printf("1\n"); else printf("0\n"); return 0; }
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
97
4
#include <iostream> using namespace std; int main(void) { int c[5]; int ans, sum; for (int i = 0; i < 6; i++) { cin >> c[i]; } sum = c[0] * 1; sum = (c[1] * 5) + sum; sum = (c[2] * 10) + sum; sum = (c[3] * 50) + sum; sum = (c[4] * 100) + sum; sum = (c[5] * 500) + sum; if (sum > 1000) ans = 1; else ans = 0; cout << ans << endl; }
#include <iostream> using namespace std; int main(void) { int c[5]; int ans, sum; for (int i = 0; i < 6; i++) { cin >> c[i]; } sum = c[0] * 1; sum = (c[1] * 5) + sum; sum = (c[2] * 10) + sum; sum = (c[3] * 50) + sum; sum = (c[4] * 100) + sum; sum = (c[5] * 500) + sum; if (sum >= 1000) ans = 1; else ans = 0; cout << ans << endl; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
142
2
import java.util.*; class Main { public static void main(String[] args) { Solve s = new Solve(); s.solve(); } } class Solve { Solve() {} Scanner in = new Scanner(System.in); void solve() { int n = in.nextInt(); for (int i = 0; i < n; i++) { int a = in.nextInt(), b = in.nextInt(); int c = (a % b == 0 ? b : a % b); System.out.println(a % b); } } } // while(in.hasNext()){ // int n = in.nextInt(); // if(n == 0) return; // }
import java.util.*; class Main { public static void main(String[] args) { Solve s = new Solve(); s.solve(); } } class Solve { Solve() {} Scanner in = new Scanner(System.in); void solve() { int n = in.nextInt(); for (int i = 0; i < n; i++) { int a = in.nextInt(), b = in.nextInt(); int c = (a % b == 0 ? b : a % b); System.out.println(c); } } } // while(in.hasNext()){ // int n = in.nextInt(); // if(n == 0) return; // }
[["-", 0, 1, 0, 492, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 492, 3, 4, 0, 16, 17, 109], ["-", 0, 1, 0, 492, 3, 4, 0, 16, 12, 22], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 22]]
3
137
4
#include <stdio.h> int main() { int Nx, K[1000] = {0}, P[1000] = {0}, i, j; scanf("%d", &Nx); for (i = 0; i < Nx; i++) { scanf("%d %d", &K[i], &P[i]); } for (j = 0; j < Nx; j++) { if (K[j] % P[j] != 0) { printf("%d\n", K[j] % P[j]); } else { printf("%d\n", &P[j]); } } return 0; }
#include <stdio.h> int main() { int Nx, K[1000] = {0}, P[1000] = {0}, i, j; scanf("%d", &Nx); for (i = 0; i < Nx; i++) { scanf("%d %d", &K[i], &P[i]); } for (j = 0; j < Nx; j++) { if (K[j] % P[j] != 0) { printf("%d\n", K[j] % P[j]); } else { printf("%d\n", P[j]); } } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67]]
0
146
1
#include <stdio.h> int main() { int N, i, P, K; scanf("%d", &N); for (i = 0; i < N; i++) { scanf("%d %d", &P, &K); if (P % K == 0) { printf("%d\n", P); } else { printf("%d\n", P % K); } } return 0; }
#include <stdio.h> int main() { int N, i, P, K; scanf("%d", &N); for (i = 0; i < N; i++) { scanf("%d %d", &P, &K); if (P % K == 0) { printf("%d\n", K); } else { printf("%d\n", P % K); } } return 0; }
[["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
0
93
2
#include <stdio.h> int main(void) { int K, P, N; scanf("%d", &N); while (N > 1) { scanf("%d", &K); scanf("%d", &P); if (K % P == 0) printf("%d\n", P); else printf("%d\n", K % P); N--; } return 0; }
#include <stdio.h> int main(void) { int K, P, N; scanf("%d", &N); while (N > 0) { scanf("%d", &K); scanf("%d", &P); if (K % P == 0) printf("%d\n", P); else printf("%d\n", K % P); N--; } return 0; }
[["-", 8, 9, 0, 52, 15, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 52, 15, 23, 0, 16, 12, 13]]
0
91
2
#include <stdio.h> int main(void) { int n, k[100], p[100], a[100], i; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d %d", &k[i], &p[i]); if (k[i] / p[i] == 0) a[i] = p[i]; else a[i] = k[i] % p[i]; } for (i = 0; i < n; i++) printf("%d\n", a[i]); return 0; }
#include <stdio.h> int main(void) { int n, k[100], p[100], a[100], i; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d %d", &k[i], &p[i]); if (k[i] % p[i] == 0) a[i] = p[i]; else a[i] = k[i] % p[i]; } for (i = 0; i < n; i++) printf("%d\n", a[i]); return 0; }
[["-", 0, 57, 15, 23, 0, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 109]]
0
142
2
#define _USE_MATH_DEFINES #define INF 0x3f3f3f3f #include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> using namespace std; typedef long long ll; typedef pair<int, string> P; static const double EPS = 1e-8; int main() { int total_games; while (~scanf("%d", &total_games)) { for (int game_i = 0; game_i < total_games; game_i++) { int num_of_stones; int num_of_players; scanf("%d %d", &num_of_stones, &num_of_players); if (num_of_stones < num_of_players) { printf("%d\n", num_of_stones); } else { if (num_of_stones % num_of_stones == 0) { printf("%d\n", num_of_players); } else { printf("%d\n", num_of_stones % num_of_stones); } } } } }
#define _USE_MATH_DEFINES #define INF 0x3f3f3f3f #include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> using namespace std; typedef long long ll; typedef pair<int, string> P; static const double EPS = 1e-8; int main() { int total_games; while (~scanf("%d", &total_games)) { for (int game_i = 0; game_i < total_games; game_i++) { int num_of_stones; int num_of_players; scanf("%d %d", &num_of_stones, &num_of_players); if (num_of_stones < num_of_players) { printf("%d\n", num_of_stones); } else { if (num_of_stones % num_of_players == 0) { printf("%d\n", num_of_players); } else { printf("%d\n", num_of_stones % num_of_players); } } } } }
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
175
4
#include <iostream> using namespace std; int main() { int K, P, n; cin >> n; for (int i = 1; i <= n; i++) { cin >> K >> P; int a; if (K % P < P && K % P != 0) { cout << K % P << endl; } if (K % P == 0) { cout << P << endl; } if (K < P) { cout << K << endl; } } }
#include <iostream> using namespace std; int main() { int K, P, n; cin >> n; for (int i = 1; i <= n; i++) { cin >> K >> P; int a; if (K % P < P && K % P != 0) { cout << K % P << endl; } else if (K % P == 0) { cout << P << endl; } else if (K < P) { cout << K << endl; } } }
[["+", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 0, 57, 75, 76, 0, 57, 75, 76, 0, 95]]
1
102
2
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; int s = 0; vector<int> a(n); vector<int> b(n); while (s <= n - 1) { cin >> a[s] >> b[s]; s++; } s = 0; while (s <= n - 1) { if (a[s] % b[s] == 0) { cout << n << endl; s++; } else { cout << a[s] % b[s] << endl; s++; } } return 0; }
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; int s = 0; vector<int> a(n); vector<int> b(n); while (s <= n - 1) { cin >> a[s] >> b[s]; s++; } s = 0; while (s <= n - 1) { if (a[s] % b[s] == 0) { cout << b[s] << endl; s++; } else { cout << a[s] % b[s] << endl; s++; } } return 0; }
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 70], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 73]]
1
131
5
#include <iostream> using std::cin; using std::cout; int main(int argc, const char *argv[]) { std::ios::sync_with_stdio(false); int stone725_is_pro; int a, b; cin >> stone725_is_pro; for (int i = 0; i < stone725_is_pro; ++i) { cin >> a >> b; cout << a % b << "\n"; } return 0; }
#include <iostream> using std::cin; using std::cout; int main(int argc, const char *argv[]) { std::ios::sync_with_stdio(false); int stone725_is_pro; int a, b; cin >> stone725_is_pro; for (int i = 0; i < stone725_is_pro; ++i) { cin >> a >> b; cout << (a - 1) % b + 1 << "\n"; } return 0; }
[["+", 31, 16, 12, 16, 31, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 12, 13], ["+", 31, 16, 12, 16, 31, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
83
6
#include <bits/stdc++.h> using namespace std; int main() { int n, k, p; for (; n--;) { cin >> k >> p; if (k % p) cout << k % p << endl; else cout << p << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n, k, p; for (cin >> n; n--;) { cin >> k >> p; if (k % p) cout << (k % p) << endl; else cout << p << endl; } }
[["+", 0, 14, 8, 9, 0, 7, 10, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 7, 10, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 7, 10, 16, 12, 22], ["+", 64, 1, 0, 16, 31, 16, 12, 23, 0, 24], ["+", 64, 1, 0, 16, 31, 16, 12, 23, 0, 25]]
1
55
5
#include <iostream> using namespace std; int main() { int n, a, b; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b; cout << (a + 2) % b + 1 << endl; } return 0; }
#include <iostream> using namespace std; int main() { int n, a, b; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b; cout << (a + b - 1) % b + 1 << endl; } return 0; }
[["-", 12, 16, 31, 16, 31, 23, 0, 16, 12, 13], ["+", 31, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 12, 13]]
1
62
4
#include <cstdio> #include <iostream> using namespace std; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int k, p; scanf("%d%d", &k, &p); printf("%d\n", (k % p == 0) ? (k / p) : (p)); } return (0); }
#include <cstdio> #include <iostream> using namespace std; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int k, p; scanf("%d%d", &k, &p); printf("%d\n", (k % p == 0) ? (p) : (k % p)); } return (0); }
[["-", 3, 4, 0, 41, 64, 23, 0, 16, 31, 22], ["-", 3, 4, 0, 41, 64, 23, 0, 16, 17, 85], ["+", 3, 4, 0, 41, 75, 23, 0, 16, 31, 22], ["+", 3, 4, 0, 41, 75, 23, 0, 16, 17, 109]]
1
92
4
#include <stdio.h> int main(void) { int a, b, N, p, i = 0, f; scanf("%d", &N); for (i = 0; i < N; i++) { scanf("%d %d", &a, &b); a = a % b; if (a == 0) a = N; printf("%d\n", a); } return 0; }
#include <stdio.h> int main(void) { int a, b, N, p, i = 0, f; scanf("%d", &N); for (i = 0; i < N; i++) { scanf("%d %d", &a, &b); a = a % b; if (a == 0) a = b; printf("%d\n", a); } return 0; }
[["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 12, 22]]
1
91
2
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; for (int i = 0; i < N; i++) { int k, p, u = 0; cin >> k >> p; while (k) { k--; u++; if (u == p) u = 0; } cout << u + 1 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; for (int i = 0; i < N; i++) { int k, p, u = -1; cin >> k >> p; while (k) { k--; u++; if (u == p) u = 0; } cout << u + 1 << endl; } return 0; }
[["-", 0, 7, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 7, 8, 9, 0, 43, 49, 50, 51, 13]]
1
83
2
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" int main() { int N; for (int i = 0; i < N; ++i) { int K, P; cin >> K >> P; int ans = K % P; if (!ans) ans += P; cout << ans << endl; } return 0; }
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" int main() { int N; cin >> N; for (int i = 0; i < N; ++i) { int K, P; cin >> K >> P; int ans = K % P; if (!ans) ans += P; cout << ans << endl; } return 0; }
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
105
4
#include <iostream> using namespace std; int main() { int a, b, c, count; cin >> a; for (int i = 0; i < a; i++) { cin >> b >> c; if (b > c && b % c != 0) cout << b % c << endl; else if (b > c && b % c == 0) cout << c << endl; else cout << b; } return 0; }
#include <iostream> using namespace std; int main() { int a, b, c, count; cin >> a; for (int i = 0; i < a; i++) { cin >> b >> c; if (b > c && b % c != 0) cout << b % c << endl; else if (b > c && b % c == 0) cout << c << endl; else cout << b << endl; } return 0; }
[["+", 0, 57, 75, 76, 0, 1, 0, 16, 17, 151], ["+", 0, 57, 75, 76, 0, 1, 0, 16, 12, 22]]
1
94
2
#include <iostream> using namespace std; int main() { int N, K, P, A; for (int i = 0; i < N; i++) { cin >> K >> P; A = K % P; if (K % P == 0) { cout << P << endl; } else { cout << A << endl; } } return 0; }
#include <iostream> using namespace std; int main() { int N, K, P, A; cin >> N; for (int i = 0; i < N; i++) { cin >> K >> P; A = K % P; if (K % P == 0) { cout << P << endl; } else { cout << A << endl; } } return 0; }
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
77
4
#include <algorithm> #include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int k[N], p[N]; for (int a = 0; a < N; ++a) { cin >> k[a] >> p[a]; } for (int i = 0; i < N; ++i) { if (k[i] % p[i] == 0) { cout << k[i] << endl; } else { cout << k[i] % p[i] << endl; } } return 0; }
#include <algorithm> #include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int k[N], p[N]; for (int a = 0; a < N; ++a) { cin >> k[a] >> p[a]; } for (int i = 0; i < N; ++i) { if (k[i] % p[i] == 0) { cout << p[i] << endl; } else { cout << k[i] % p[i] << endl; } } return 0; }
[["-", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22]]
1
121
2
#include <iostream> using namespace std; int main() { int N = 0; int K[10000], P[10000]; cin >> N; for (int i = 0; i < N; i++) { cin >> K[i]; P[i]; } for (int i = 0; i < N; i++) { int ans = K[i] % P[i]; if (ans == 0) { cout << P[i] << endl; } else { cout << ans << endl; } } return 0; }
#include <iostream> using namespace std; int main() { int N = 0; int K[10000], P[10000]; cin >> N; for (int i = 0; i < N; i++) { cin >> K[i]; cin >> P[i]; } for (int i = 0; i < N; i++) { int ans = K[i] % P[i]; if (ans == 0) { cout << P[i] << endl; } else { cout << ans << endl; } } return 0; }
[["+", 0, 7, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 152]]
1
118
2
#include <iostream> using namespace std; int main() { int n, k, p; cin >> n; for (int i = 0; i < n; i++) { cin >> k >> p; int a = k % p; if (a == 0) cout << p; else cout << a; } return 0; }
#include <iostream> using namespace std; int main() { int n, k, p; cin >> n; for (int i = 0; i < n; i++) { cin >> k >> p; int a = k % p; if (a == 0) cout << p; else cout << a; cout << endl; } return 0; }
[["+", 0, 7, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
70
4
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { int N; for (int i = 0; i < N; i++) { int K, P; cin >> K >> P; int ans = K % P; cout << (ans == 0 ? P : ans) << endl; } }
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { int N; cin >> N; for (int i = 0; i < N; i++) { int K, P; cin >> K >> P; int ans = K % P; cout << (ans == 0 ? P : ans) << endl; } }
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
67
4
#include <iostream> using namespace std; int main() { int n, s, h; int i, ans; cin >> n; for (i = 0; i < n; i++) { cin >> s >> h; ans = s / h; if (ans == 0) cout << h << endl; else cout << ans << endl; } return 0; }
#include <iostream> using namespace std; int main() { int n, s, h; int i, ans; cin >> n; for (i = 0; i < n; i++) { cin >> s >> h; ans = s % h; if (ans == 0) cout << h << endl; else cout << ans << endl; } return 0; }
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 85], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109]]
1
77
2
gets.to_i.times do k, p = gets.split.map(&:to_i) put((k - 1) % p + 1) end
gets.to_i.times do k, p = gets.split.map(&:to_i) puts((k - 1) % p + 1) end
[["-", 0, 652, 196, 737, 8, 736, 0, 652, 735, 22], ["+", 0, 652, 196, 737, 8, 736, 0, 652, 735, 22]]
4
32
2
n = eval(input()) for i in range(n): a, b = list(map(int, input().split())) if a / b == 0: print(b) else: print(a % b)
n = eval(input()) for i in range(n): a, b = list(map(int, input().split())) if a % b == 0: print(b) else: print(a % b)
[["-", 8, 196, 0, 57, 15, 666, 0, 657, 17, 85], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 109]]
5
54
2
for _ in range(int(input())): k, p= map(int, input().split()) print(p if k%p else k%p)
for _ in range(int(input())): k, p= map(int, input().split()) print(p if k%p==0 else k%p)
[["+", 0, 652, 3, 4, 0, 41, 0, 666, 667, 60], ["+", 0, 652, 3, 4, 0, 41, 0, 666, 0, 612]]
5
41
2
for _ in range(int(input())): a,b = map(int,input().split()) print(a%b+1)
for _ in range(int(input())): a,b = map(int,input().split()) print((a-1)%b+1)
[["+", 3, 4, 0, 657, 31, 657, 31, 23, 0, 24], ["+", 0, 657, 31, 657, 31, 23, 0, 657, 17, 33], ["+", 0, 657, 31, 657, 31, 23, 0, 657, 12, 612], ["+", 3, 4, 0, 657, 31, 657, 31, 23, 0, 25]]
5
37
4
import java.util.*; class Main { int a, b; int n, m; int[][] flg = new int[24][60]; Main() { Scanner sc = new Scanner(System.in); n = sc.nextInt(); for (int i = 0; i < n; i++) { a = sc.nextInt(); b = sc.nextInt(); flg[a][b] = 1; } m = sc.nextInt(); for (int i = 0; i < m; i++) { a = sc.nextInt(); b = sc.nextInt(); flg[a][b] = 1; } int cnt = 0; for (int i = 0; i < 24; i++) { for (int j = 0; j < 60; j++) { if (flg[i][j] == 0) continue; cnt++; if (cnt > 1) System.out.print(" "); System.out.print(i + " " + j / 10 + j % 10); } } System.out.println(); } public static void main(String[] args) { new Main(); } }
import java.util.*; class Main { int a, b; int n, m; int[][] flg = new int[24][60]; Main() { Scanner sc = new Scanner(System.in); n = sc.nextInt(); for (int i = 0; i < n; i++) { a = sc.nextInt(); b = sc.nextInt(); flg[a][b] = 1; } m = sc.nextInt(); for (int i = 0; i < m; i++) { a = sc.nextInt(); b = sc.nextInt(); flg[a][b] = 1; } int cnt = 0; for (int i = 0; i < 24; i++) { for (int j = 0; j < 60; j++) { if (flg[i][j] == 0) continue; cnt++; if (cnt > 1) System.out.print(" "); System.out.print(i + ":" + j / 10 + j % 10); } } System.out.println(); } public static void main(String[] args) { new Main(); } }
[["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 491], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 491]]
3
270
2
#include <stdio.h> int main(void) { int n; int h, m; int i, j; int bus[24][60] = {0}; int c; for (i = 0; i < 2; i++) { scanf("%d", &n); for (j = 0; j < n; j++) { scanf("%d %d", &h, &m); bus[h][m] = 1; } } c = 0; for (h = 0; h < 24; h++) { for (m = 0; m < 60; m++) { if (bus[h][m]) { if (c == 0) { printf(" "); } c = 1; printf("%d:%02d", h, m); } } } printf("\n"); return (0); }
#include <stdio.h> int main(void) { int n; int h, m; int i, j; int bus[24][60] = {0}; int c; for (i = 0; i < 2; i++) { scanf("%d", &n); for (j = 0; j < n; j++) { scanf("%d %d", &h, &m); bus[h][m] = 1; } } c = 0; for (h = 0; h < 24; h++) { for (m = 0; m < 60; m++) { if (bus[h][m]) { if (c == 1) { printf(" "); } c = 1; printf("%d:%02d", h, m); } } } printf("\n"); return (0); }
[["-", 64, 9, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 23, 0, 16, 12, 13]]
0
189
2
#include "bits/stdc++.h" using namespace std; using LL = long long; using ULL = unsigned long long; const double PI = acos(-1); template <class T> constexpr T INF() { return ::std::numeric_limits<T>::max(); } template <class T> constexpr T HINF() { return INF<T>() / 2; } template <typename T_char> T_char TL(T_char cX) { return tolower(cX); }; template <typename T_char> T_char TU(T_char cX) { return toupper(cX); }; const int vy[] = {-1, -1, -1, 0, 1, 1, 1, 0}, vx[] = {-1, 0, 1, 1, 1, 0, -1, -1}; const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1}; const char dir[4] = {'u', 'l', 'd', 'r'}; int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++) if ((n >> i) & 1) cnt++; return cnt; } int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; } return ret; } int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; } return ret; } LL gcd(LL a, LL b) { if (b == 0) return a; return gcd(b, a % b); }; LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g * b; }; #define ALL(qpqpq) (qpqpq).begin(), (qpqpq).end() #define UNIQUE(wpwpw) (wpwpw).erase(unique(ALL((wpwpw))), (wpwpw).end()) #define LOWER(epepe) transform(ALL((epepe)), (epepe).begin(), TL<char>) #define UPPER(rprpr) transform(ALL((rprpr)), (rprpr).begin(), TU<char>) #define FOR(i, tptpt, ypypy) for (LL i = (tptpt); i < (ypypy); i++) #define REP(i, upupu) FOR(i, 0, upupu) #define INIT \ std::ios::sync_with_stdio(false); \ std::cin.tie(0) #pragma warning(disable : 4996) vector<pair<int, int>> v; int n, m; int main() { cin >> n; REP(i, n) { int a, b; cin >> a >> b; v.emplace_back(make_pair(a, b)); } cin >> m; REP(i, m) { int a, b; cin >> a >> b; v.emplace_back(make_pair(a, b)); } sort(ALL(v)); UNIQUE(v); REP(i, n + m) { if (i) cout << " "; cout << v[i].first << ":" << (v[i].second < 10 ? "0" : "") << v[i].second; } cout << endl; // system("pause"); }
#include "bits/stdc++.h" using namespace std; using LL = long long; using ULL = unsigned long long; const double PI = acos(-1); template <class T> constexpr T INF() { return ::std::numeric_limits<T>::max(); } template <class T> constexpr T HINF() { return INF<T>() / 2; } template <typename T_char> T_char TL(T_char cX) { return tolower(cX); }; template <typename T_char> T_char TU(T_char cX) { return toupper(cX); }; const int vy[] = {-1, -1, -1, 0, 1, 1, 1, 0}, vx[] = {-1, 0, 1, 1, 1, 0, -1, -1}; const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1}; const char dir[4] = {'u', 'l', 'd', 'r'}; int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++) if ((n >> i) & 1) cnt++; return cnt; } int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; } return ret; } int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; } return ret; } LL gcd(LL a, LL b) { if (b == 0) return a; return gcd(b, a % b); }; LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g * b; }; #define ALL(qpqpq) (qpqpq).begin(), (qpqpq).end() #define UNIQUE(wpwpw) (wpwpw).erase(unique(ALL((wpwpw))), (wpwpw).end()) #define LOWER(epepe) transform(ALL((epepe)), (epepe).begin(), TL<char>) #define UPPER(rprpr) transform(ALL((rprpr)), (rprpr).begin(), TU<char>) #define FOR(i, tptpt, ypypy) for (LL i = (tptpt); i < (ypypy); i++) #define REP(i, upupu) FOR(i, 0, upupu) #define INIT \ std::ios::sync_with_stdio(false); \ std::cin.tie(0) #pragma warning(disable : 4996) vector<pair<int, int>> v; int n, m; int main() { cin >> n; REP(i, n) { int a, b; cin >> a >> b; v.emplace_back(make_pair(a, b)); } cin >> m; REP(i, m) { int a, b; cin >> a >> b; v.emplace_back(make_pair(a, b)); } sort(ALL(v)); UNIQUE(v); REP(i, v.size()) { if (i) cout << " "; cout << v[i].first << ":" << (v[i].second < 10 ? "0" : "") << v[i].second; } cout << endl; // system("pause"); }
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 28, 22], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 17, 131], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
607
8
#include <algorithm> #include <iostream> #include <map> using namespace std; typedef pair<int, int> P; int main() { int n, m; int ho, mi; P p[202]; cin >> n; for (int i = 0; i < n; i++) { cin >> ho >> mi; p[i].first = ho; p[i].second = mi; } cin >> m; for (int i = n; i < n + m; i++) { cin >> ho >> mi; p[i].first = ho; p[i].second = mi; } sort(p, p + (m + n)); int cou = 0; for (int i = 0; i < n + m; i++) { if (i == 0) { if (p[i].second < 10) { if (cou == 1) { cout << " "; } cou = 1; cout << p[i].first << ":0" << p[i].second; } else { if (cou == 0) { cout << " "; } cou = 1; cout << p[i].first << ":" << p[i].second; } } else if (p[i].first != p[i - 1].first || p[i].second != p[i - 1].second) { if (p[i].second < 10) { if (cou == 0) { cout << " "; } cou = 1; cout << p[i].first << ":0" << p[i].second; } else { if (cou == 0) { cout << " "; } cou = 1; cout << p[i].first << ":" << p[i].second; } } } cout << endl; }
#include <algorithm> #include <iostream> #include <map> using namespace std; typedef pair<int, int> P; int main() { int n, m; int ho, mi; P p[202]; cin >> n; for (int i = 0; i < n; i++) { cin >> ho >> mi; p[i].first = ho; p[i].second = mi; } cin >> m; for (int i = n; i < n + m; i++) { cin >> ho >> mi; p[i].first = ho; p[i].second = mi; } sort(p, p + (m + n)); int cou = 0; for (int i = 0; i < n + m; i++) { if (i == 0) { if (p[i].second < 10) { if (cou == 1) { cout << " "; } cou = 1; cout << p[i].first << ":0" << p[i].second; } else { if (cou == 1) { cout << " "; } cou = 1; cout << p[i].first << ":" << p[i].second; } } else if (p[i].first != p[i - 1].first || p[i].second != p[i - 1].second) { if (p[i].second < 10) { if (cou == 1) { cout << " "; } cou = 1; cout << p[i].first << ":0" << p[i].second; } else { if (cou == 1) { cout << " "; } cou = 1; cout << p[i].first << ":" << p[i].second; } } } cout << endl; }
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
400
6
#include <iostream> using namespace std; int main() { int N = 0; int h[201]; int m[201]; int M = 0; int k[201]; int g[201]; int L = 0; cin >> N; int tem = 0; int i = 0; int AH[201]; int AM[201]; int DH = 100; int DM = 100; for (int i = 0; i < N; i++) { cin >> h[i] >> m[i]; } cin >> M; for (int i = 0; i < M; i++) { cin >> k[i] >> g[i]; } int A = N + M; for (int i = 0; i < M; i++) { h[N + i] = k[i]; m[N + i] = g[i]; } for (int i = 0; i < A - 1; i++) { for (int q = i; q < A - 1; q++) { if (h[i] > h[q + 1]) { tem = h[i]; h[i] = h[q + 1]; h[q + 1] = tem; tem = m[i]; m[i] = m[q + 1]; m[q + 1] = tem; } } } for (int i = 0; i < A - 1; i++) { for (int q = i; q < A - 1; q++) { if ((h[i] == h[q + 1]) && (m[i] > m[q + 1])) { tem = m[i]; m[i] = m[q + 1]; m[q + 1] = tem; } } } int cont = 0; for (int i = 0; i < A - 1; i++) { if ((DH != h[i]) || (DM != m[i])) { AH[cont] = h[i]; DH = h[i]; AM[cont] = m[i]; DM = m[i]; cont++; } } for (int i = 0; i < cont; i++) { if (m[i] < 10) { cout << AH[i] << ":0" << AM[i]; } else { cout << AH[i] << ":" << AM[i]; } if (i < cont - 1) { cout << " "; } } cout << endl; return 0; }
#include <iostream> using namespace std; int main() { int N = 0; int h[201]; int m[201]; int M = 0; int k[201]; int g[201]; int L = 0; cin >> N; int tem = 0; int i = 0; int AH[201]; int AM[201]; int DH = 100; int DM = 100; for (int i = 0; i < N; i++) { cin >> h[i] >> m[i]; } cin >> M; for (int i = 0; i < M; i++) { cin >> k[i] >> g[i]; } int A = N + M; for (int i = 0; i < M; i++) { h[N + i] = k[i]; m[N + i] = g[i]; } for (int i = 0; i < A - 1; i++) { for (int q = i; q < A - 1; q++) { if (h[i] > h[q + 1]) { tem = h[i]; h[i] = h[q + 1]; h[q + 1] = tem; tem = m[i]; m[i] = m[q + 1]; m[q + 1] = tem; } } } for (int i = 0; i < A - 1; i++) { for (int q = i; q < A - 1; q++) { if ((h[i] == h[q + 1]) && (m[i] > m[q + 1])) { tem = m[i]; m[i] = m[q + 1]; m[q + 1] = tem; } } } int cont = 0; for (int i = 0; i < A; i++) { if ((DH != h[i]) || (DM != m[i])) { AH[cont] = h[i]; DH = h[i]; AM[cont] = m[i]; DM = m[i]; cont++; } } for (int i = 0; i < cont; i++) { if (AM[i] <= 9) { cout << AH[i] << ":0" << AM[i]; } else { cout << AH[i] << ":" << AM[i]; } if (i < cont - 1) { cout << " "; } } cout << endl; return 0; }
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
565
8
def f(a, b) result = 0 unless a == b result += 1 unless a % 2 == 0 result += 1 unless b % 2 == 0 a = (a + 1) / 2 b = b / 2 end result end n = gets.to_i n.times do s, d = gets.split.map!(&:to_i) puts f(s, d) end
def f(a, b) result = 0 until a == b result += 1 unless a % 2 == 0 result += 1 unless b % 2 == 0 a = (a + 1) / 2 b = b / 2 end result end n = gets.to_i n.times do s, d = gets.split.map!(&:to_i) puts f(s, d) end
[["-", 0, 493, 0, 735, 8, 736, 0, 747, 0, 747], ["+", 0, 493, 0, 735, 8, 736, 0, 750, 0, 750]]
4
79
2
#include <stdio.h> int main(void) { int a, b; scanf("%d%d", &a, &b); printf("%d\n", a + b); return 0; }
#include <stdio.h> int main(void) { int a, b; scanf("%d%d", &a, &b); printf("%d\n", a * b); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 48]]
0
42
2
#include <stdio.h> int main() { int d, c; scanf("%d %d", &d, &c); c = 2 * d; printf("%d\n", c); return 0; }
#include <stdio.h> int main() { int d, c, b; scanf("%d %d", &d, &c); b = c * d; printf("%d\n", b); return 0; }
[["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 31, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
0
45
8
#include <stdio.h> int main(void) { int d, c; scanf("%d %d", d, c); printf("%d\n", d * c); return 0; }
#include <stdio.h> int main(void) { int d, c; scanf("%d %d", &d, &c); printf("%d\n", d * c); return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67]]
0
40
2
#include <iostream> int main() { int a, b; std::cin >> a, b; std::cout << a * b << std::endl; return 0; }
#include <iostream> int main() { int a, b; std::cin >> a >> b; std::cout << a * b << std::endl; return 0; }
[["-", 0, 14, 8, 9, 0, 1, 0, 34, 0, 21], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152]]
1
36
2
#include <stdio.h> int main() { int x, y, z = 0; while (scanf("%d %d", &x, &y) != EOF) { z = x * y; printf("%d\n", &z); z = 0; } return 0; }
#include <stdio.h> int main() { int x, y, z = 0; while (scanf("%d %d", &x, &y) != EOF) { z = x * y; printf("%d\n", z); z = 0; } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67]]
1
60
1
#include <cstdio> #include <cstdlib> #include <cstring> int main() { int d, c; scanf("%d%d", &d, &c); printf("%d %d", d, c); return 0; }
#include <cstdio> #include <cstdlib> #include <cstring> int main() { int d, c; scanf("%d%d", &d, &c); printf("%d\n", d * c); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 48]]
1
44
5
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int N; int R; int S, T; int pos[114514]; int bit[(1 << 18) + 2]; ll kai[114514]; ll mod = 1000000007; int sum(int i) { int s = 0; while (i > 0) { s += bit[i]; i -= i & -i; } return s; } void add(int i) { while (i <= (1 << 18)) { bit[i]++; i += i & -i; } } int main() { while (true) { scanf("%d", &N); for (int i = 0; i < N; i++) { pos[i] = i; } for (int i = 0; i < (1 << 18) + 2; i++) { bit[i] = 0; } if (N == 0) return 0; scanf("%d", &R); for (int i = 0; i < R; i++) { scanf("%d%d", &S, &T); S--; T--; swap(pos[S], pos[T]); } kai[1] = 1; for (int i = 2; i < 114514; i++) { kai[i] = (kai[i - 1] * (ll)i) % mod; } ll ans = 0; for (int i = N - 1; i >= 0; i--) { ans += (kai[i + 1] * (ll)sum(pos[i])) % mod; // printf("%d\n",sum(pos[i])); add(pos[i] + 1); ans %= mod; } printf("%lld\n", ans); } }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int N; int R; int S, T; int pos[114514]; int bit[(1 << 18) + 2]; ll kai[114514]; ll mod = 1000000007; int sum(int i) { int s = 0; while (i > 0) { s += bit[i]; i -= i & -i; } return s; } void add(int i) { while (i <= (1 << 18)) { bit[i]++; i += i & -i; } } int main() { while (true) { scanf("%d", &N); for (int i = 0; i < N; i++) { pos[i] = i; } for (int i = 0; i < (1 << 18) + 2; i++) { bit[i] = 0; } if (N == 0) return 0; scanf("%d", &R); for (int i = 0; i < R; i++) { scanf("%d%d", &S, &T); S--; T--; swap(pos[S], pos[T]); } kai[1] = 1; for (int i = 2; i < 114514; i++) { kai[i] = (kai[i - 1] * (ll)i) % mod; } ll ans = 0; for (int i = N - 1; i >= 0; i--) { ans += (kai[N - i - 1] * (ll)sum(pos[i])) % mod; // printf("%d\n",sum(pos[i])); add(pos[i] + 1); ans %= mod; } printf("%lld\n", ans); } }
[["+", 31, 69, 341, 342, 0, 16, 31, 16, 31, 22], ["+", 31, 69, 341, 342, 0, 16, 31, 16, 17, 33], ["-", 0, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["+", 0, 16, 31, 69, 341, 342, 0, 16, 17, 33]]
1
380
4
import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } private void run() { Scanner scanner = new Scanner(System.in); while (true) { int n = scanner.nextInt(); if (n == 0) break; Integer[] a = new Integer[n]; Integer[] b = new Integer[n]; for (int i = 0; i < n; i++) a[i] = scanner.nextInt(); for (int i = 0; i < n; i++) b[i] = scanner.nextInt(); Arrays.sort(a, Collections.reverseOrder()); Arrays.sort(b, Collections.reverseOrder()); n /= 2; for (int i = 0; i < n; i++) { if (a[i * 2] > b[i]) { System.out.println((i * 2) + 1); break; } } System.out.println("NA"); } } }
import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } private void run() { Scanner scanner = new Scanner(System.in); loop: while (true) { int n = scanner.nextInt(); if (n == 0) break; Integer[] a = new Integer[n]; Integer[] b = new Integer[n]; for (int i = 0; i < n; i++) a[i] = scanner.nextInt(); for (int i = 0; i < n; i++) b[i] = scanner.nextInt(); Arrays.sort(a, Collections.reverseOrder()); Arrays.sort(b, Collections.reverseOrder()); n /= 2; for (int i = 0; i < n; i++) { if (a[i * 2] > b[i]) { System.out.println((i * 2) + 1); continue loop; } } System.out.println("NA"); } } }
[["+", 8, 498, 0, 195, 8, 196, 0, 97, 0, 22], ["+", 8, 498, 0, 195, 8, 196, 0, 97, 0, 102], ["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 22]]
3
250
5
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; int n; int A[40001], B[40001]; int check(int k, set<P> S) { int win = 0; for (int i = n - k - 1; i < n; i++) { set<P>::iterator it = S.upper_bound(P(B[i], -1)); if (it == S.end()) it--; if (it->second < k) continue; win++; S.erase(it); } return win > k / 2; } int main() { while (cin >> n, n) { for (int i = 0; i < n; i++) cin >> A[i]; for (int i = 0; i < n; i++) cin >> B[i]; sort(A, A + n, greater<int>()); sort(B, B + n, greater<int>()); int ans = 0, idx = 0, win = 0; for (int i = 0; i < n; i++) { if (B[idx] > A[i]) idx++; else if (B[idx] < A[i]) win++; ans = i + 1; if ((i + 1) / 2 < win) break; } if (ans < n) cout << ans << endl; else cout << "NA" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; int n; int A[40001], B[40001]; int check(int k, set<P> S) { int win = 0; for (int i = n - k - 1; i < n; i++) { set<P>::iterator it = S.upper_bound(P(B[i], -1)); if (it == S.end()) it--; if (it->second < k) continue; win++; S.erase(it); } return win > k / 2; } int main() { while (cin >> n, n) { for (int i = 0; i < n; i++) cin >> A[i]; for (int i = 0; i < n; i++) cin >> B[i]; sort(A, A + n, greater<int>()); sort(B, B + n, greater<int>()); int ans = 0, idx = 0, win = 0; for (int i = 0; i < n; i++) { if (B[idx] >= A[i]) idx++; else if (B[idx] < A[i]) win++; ans = i + 1; if ((i + 1) / 2 < win) break; } if (ans < n) cout << ans << endl; else cout << "NA" << endl; } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
325
2
#include <bits/stdc++.h> #define N 40005 using namespace std; int n, a[N], b[N], A[N]; int main() { while (1) { cin >> n; if (!n) break; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; sort(a, a + n, greater<int>()); sort(b, b + n, greater<int>()); for (int i = 0; i < n; i++) A[i] = n; int x = 0; for (int i = 0; i < n; i++) for (int j = x; j < n; j++) if (b[i] >= a[j]) { A[j] = i; x = j + 1; break; } int cnt = 0, ans = n; for (int i = 0; i < n; i++) { if (A[i] != n) cnt++; if (cnt > (i + 2) / 2) ans = min(ans, i + 1); } if (ans == n) cout << "NA" << endl; else cout << ans << endl; } return 0; }
#include <bits/stdc++.h> #define N 40005 using namespace std; int n, a[N], b[N], A[N]; int main() { while (1) { cin >> n; if (!n) break; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; sort(a, a + n, greater<int>()); sort(b, b + n, greater<int>()); for (int i = 0; i < n; i++) A[i] = n; int x = 0; for (int i = 0; i < n; i++) for (int j = x; j < n; j++) if (b[i] >= a[j]) { A[j] = i; x = j + 1; break; } int cnt = 0, ans = n; for (int i = 0; i < n; i++) { if (A[i] != n) cnt++; if (cnt < (i + 2) / 2) ans = min(ans, i + 1); } if (ans == n) cout << "NA" << endl; else cout << ans << endl; } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
291
2
#include <bits/stdc++.h> #define REP(i, s, n) for (int i = s; i < n; i++) #define rep(i, n) REP(i, 0, n) #define IINF (INT_MAX) #define MAX_N 40001 using namespace std; int N, a[MAX_N], b[MAX_N]; int main() { while (scanf("%d", &N), N) { rep(i, N) scanf("%d", a + i); rep(i, N) scanf("%d", b + i); sort(a, a + N, greater<int>()); sort(b, b + N, greater<int>()); bool won = false; int cnt = 0, cur = 0; rep(i, N - 1) { if (a[i] <= b[cur]) cnt++, cur++; if ((i + 1) / 2.0 < (i + 1) - cnt) { won = true; cout << i + 1 << endl; } } if (!won) cout << "NA" << endl; } return 0; }
#include <bits/stdc++.h> #define REP(i, s, n) for (int i = s; i < n; i++) #define rep(i, n) REP(i, 0, n) #define IINF (INT_MAX) #define MAX_N 40001 using namespace std; int N, a[MAX_N], b[MAX_N]; int main() { while (scanf("%d", &N), N) { rep(i, N) scanf("%d", a + i); rep(i, N) scanf("%d", b + i); sort(a, a + N, greater<int>()); sort(b, b + N, greater<int>()); bool won = false; int cnt = 0, cur = 0; rep(i, N - 1) { if (a[i] <= b[cur]) cnt++, cur++; if ((i + 1) / 2.0 < (i + 1) - cnt) { won = true; cout << i + 1 << endl; break; } } if (!won) cout << "NA" << endl; } return 0; }
[["+", 0, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 0, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
222
2
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <iostream> #include <vector> #define TIMES(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef complex<double> P; typedef bitset<300> Spec; const double EPS = 1e-9; const double PI = acos(-1); double normalize(double angle) { if (angle < 0) return angle + 2 * PI; return angle; } int cmp(double a, double b) { const double diff = a - b; if (fabs(diff) < EPS) return 0; return diff < 0 ? -1 : 1; } double dot(const P &a, const P &b) { return a.real() * b.real() + a.imag() * b.imag(); } double cross(const P &a, const P &b) { return a.real() * b.imag() - a.imag() * b.real(); } int root(int n, vector<int> &roots) { if (roots[n] == n) return n; return roots[n] = root(roots[n], roots); } bool unite(int a, int b, vector<int> &roots) { const int ra = root(a, roots); const int rb = root(b, roots); if (ra == rb) return false; roots[ra] = rb; return true; } bool solve() { int C, W; cin >> C >> W; if (!C && !W) return false; vector<P> poles; vector<vector<int>> graph(C); vector<vector<int>> wall_id(C, vector<int>(C)); TIMES(_, C) { double x, y; cin >> x >> y; poles.push_back(P(x, y)); } TIMES(i, W) { int s, t; cin >> s >> t; --s; --t; graph[s].push_back(t); graph[t].push_back(s); wall_id[s][t] = i * 2; wall_id[t][s] = i * 2 + 1; } vector<int> roots(W * 2); TIMES(i, W * 2) { roots[i] = i; } TIMES(i, C) { const P &pi = poles[i]; for (int j : graph[i]) { const P &pj = poles[j]; const P vec = pj - pi; const double len = abs(vec); int candidate = -1; int sin_sgn = -2; double cos_val = 2; for (int k : graph[j]) { if (k == i) continue; const P vec2 = poles[k] - pj; const int sgn = cmp(cross(vec2, vec), 0); const double cv = dot(vec, vec2) / len / abs(vec2) * sgn; if (sgn > sin_sgn || (sgn == sin_sgn && cmp(cv, cos_val) < 0)) { candidate = k; sin_sgn = sgn; cos_val = cv; } } if (candidate != -1) { if (unite(wall_id[i][j], wall_id[j][candidate], roots) && false) { cout << "unitea " << i << " " << j << " " << candidate << endl; TIMES(a, W * 2) { cout << root(a, roots) << ' '; } cout << endl; } } } } // Determine outside region const int rightmost = distance( poles.begin(), max_element(poles.begin(), poles.end(), [](const P &a, const P &b) { return a.real() < b.real(); })); const int rm_next = *min_element( graph[rightmost].begin(), graph[rightmost].end(), [&poles, rightmost](int a, int b) { const double arga = normalize(arg(poles[a] - poles[rightmost])); const double argb = normalize(arg(poles[b] - poles[rightmost])); return arga < argb; }); const int out_id = root(wall_id[rm_next][rightmost], roots); Spec init; vector<Spec> areas(W * 2); TIMES(i, W * 2) { const int area = root(i, roots); areas[area][i / 2] = true; if (area == out_id) init[i / 2] = true; // cout << area << ' '; } /* for(const Spec &s : areas) { if(s.any()) cout << s << endl; } */ // cout << endl; Spec cur = init; // cout << init << endl; int turn = 0; vector<bool> used(W * 2, false); while (true) { Spec next = cur; bool changed = false; TIMES(i, W * 2) { if (!used[i] && (areas[i] & cur).any()) { next |= areas[i]; used[i] = true; changed = true; } } if (!changed) break; cur = next; ++turn; } cout << turn << endl; return true; } int main() { cin.tie(0); ios::sync_with_stdio(0); while (solve()) ; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <iostream> #include <vector> #define TIMES(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef complex<double> P; typedef bitset<300> Spec; const double EPS = 1e-9; const double PI = acos(-1); double normalize(double angle) { if (angle < 0) return angle + 2 * PI; return angle; } int cmp(double a, double b) { const double diff = a - b; if (fabs(diff) < EPS) return 0; return diff < 0 ? -1 : 1; } double dot(const P &a, const P &b) { return a.real() * b.real() + a.imag() * b.imag(); } double cross(const P &a, const P &b) { return a.real() * b.imag() - a.imag() * b.real(); } int root(int n, vector<int> &roots) { if (roots[n] == n) return n; return roots[n] = root(roots[n], roots); } bool unite(int a, int b, vector<int> &roots) { const int ra = root(a, roots); const int rb = root(b, roots); if (ra == rb) return false; roots[ra] = rb; return true; } bool solve() { int C, W; cin >> C >> W; if (!C && !W) return false; vector<P> poles; vector<vector<int>> graph(C); vector<vector<int>> wall_id(C, vector<int>(C)); TIMES(_, C) { double x, y; cin >> x >> y; poles.push_back(P(x, y)); } TIMES(i, W) { int s, t; cin >> s >> t; --s; --t; graph[s].push_back(t); graph[t].push_back(s); wall_id[s][t] = i * 2; wall_id[t][s] = i * 2 + 1; } vector<int> roots(W * 2); TIMES(i, W * 2) { roots[i] = i; } TIMES(i, C) { const P &pi = poles[i]; for (int j : graph[i]) { const P &pj = poles[j]; const P vec = pj - pi; const double len = abs(vec); int candidate = -1; int sin_sgn = -2; double cos_val = 2; for (int k : graph[j]) { if (k == i) continue; const P vec2 = poles[k] - pj; const int sgn = cmp(cross(vec, vec2), 0); const double cv = dot(vec, vec2) / len / abs(vec2) * sgn; if (sgn > sin_sgn || (sgn == sin_sgn && cmp(cv, cos_val) < 0)) { candidate = k; sin_sgn = sgn; cos_val = cv; } } if (candidate != -1) { if (unite(wall_id[i][j], wall_id[j][candidate], roots) && false) { cout << "unitea " << i << " " << j << " " << candidate << endl; TIMES(a, W * 2) { cout << root(a, roots) << ' '; } cout << endl; } } } } // Determine outside region const int rightmost = distance( poles.begin(), max_element(poles.begin(), poles.end(), [](const P &a, const P &b) { return a.real() < b.real(); })); const int rm_next = *min_element( graph[rightmost].begin(), graph[rightmost].end(), [&poles, rightmost](int a, int b) { const double arga = normalize(arg(poles[a] - poles[rightmost])); const double argb = normalize(arg(poles[b] - poles[rightmost])); return arga < argb; }); const int out_id = root(wall_id[rm_next][rightmost], roots); Spec init; vector<Spec> areas(W * 2); TIMES(i, W * 2) { const int area = root(i, roots); areas[area][i / 2] = true; if (area == out_id) init[i / 2] = true; // cout << area << ' '; } /* for(const Spec &s : areas) { if(s.any()) cout << s << endl; } */ // cout << endl; Spec cur = init; // cout << init << endl; int turn = 0; vector<bool> used(W * 2, false); while (true) { Spec next = cur; bool changed = false; TIMES(i, W * 2) { if (!used[i] && (areas[i] & cur).any()) { next |= areas[i]; used[i] = true; changed = true; } } if (!changed) break; cur = next; ++turn; } cout << turn << endl; return true; } int main() { cin.tie(0); ios::sync_with_stdio(0); while (solve()) ; return 0; }
[["-", 51, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["-", 51, 2, 3, 4, 0, 2, 3, 4, 0, 21], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 21], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 22]]
1
1,128
4
### subroutines def make_area(an, w) w[3] = an area = [w] start = w[0] while w[1] != start c1 = w[1] w1 = w[4] links1 = $links[c1] nl1 = links1.length wi = links1.index(w1) w = links1[(wi + nl1 - 1) % nl1] w[3] = an area << w end area end ### main while true $cn, $wn = gets.strip.split(' ').map{|s| s.to_i} break if $cn == 0 && $wn == 0 $clmns = $cn.times.map{gets.strip.split(' ').map{|s| s.to_i}} $walls = $cn.times.map{[]} $links = $cn.times.map{[]} $wn.times do c0, c1 = gets.strip.split(' ').map{|s| s.to_i} c0 -= 1 c1 -= 1 x0, y0 = $clmns[c0] x1, y1 = $clmns[c1] w0 = $walls[c0][c1] = [c0, c1, Math.atan2(y1 - y0, x1 - x0), nil] w1 = $walls[c1][c0] = [c1, c0, Math.atan2(y0 - y1, x0 - x1), nil] w0[4] = w1 w1[4] = w0 $links[c0] << w0 $links[c1] << w1 end #p $walls for c in (0...$cn) $links[c].sort!{|wa, wb| wa[2] <=> wb[2]} end #p $links an = 0 $areas = [] for ci in (0...$cn) for wi in $links[c].each_index w = $links[ci][wi] if w[3].nil? $areas << make_area(an, w) an += 1 end end end #p an #$areas.each{|ar| p ar.map{|w| $clmns[w[0]]}} cimin = (0...$cn).min{|a, b| $clmns[a] <=> $clmns[b]} s_area = $links[cimin].last[3] #p cimin #p s_area dists = an.times.map{an + 1} dists[s_area] = 0 visited = [] visited[s_area] = 1 q = [s_area] while ! q.empty? a0 = q.shift for w0 in $areas[a0] a1 = w0[4][3] if visited[a1].nil? visited[a1] = 1 dists[a1] = dists[a0] + 1 q << a1 end end end puts dists.max end
### subroutines def make_area(an, w) w[3] = an area = [w] start = w[0] while w[1] != start c1 = w[1] w1 = w[4] links1 = $links[c1] nl1 = links1.length wi = links1.index(w1) w = links1[(wi + nl1 - 1) % nl1] w[3] = an area << w end area end ### main while true $cn, $wn = gets.strip.split(' ').map{|s| s.to_i} break if $cn == 0 && $wn == 0 $clmns = $cn.times.map{gets.strip.split(' ').map{|s| s.to_i}} $walls = $cn.times.map{[]} $links = $cn.times.map{[]} $wn.times do c0, c1 = gets.strip.split(' ').map{|s| s.to_i} c0 -= 1 c1 -= 1 x0, y0 = $clmns[c0] x1, y1 = $clmns[c1] w0 = $walls[c0][c1] = [c0, c1, Math.atan2(y1 - y0, x1 - x0), nil] w1 = $walls[c1][c0] = [c1, c0, Math.atan2(y0 - y1, x0 - x1), nil] w0[4] = w1 w1[4] = w0 $links[c0] << w0 $links[c1] << w1 end #p $walls for c in (0...$cn) $links[c].sort!{|wa, wb| wa[2] <=> wb[2]} end #p $links an = 0 $areas = [] for ci in (0...$cn) for wi in $links[ci].each_index w = $links[ci][wi] if w[3].nil? $areas << make_area(an, w) an += 1 end end end #p an #$areas.each{|ar| p ar.map{|w| $clmns[w[0]]}} cimin = (0...$cn).min{|a, b| $clmns[a] <=> $clmns[b]} s_area = $links[cimin].last[3] #p cimin #p s_area dists = an.times.map{an + 1} dists[s_area] = 0 visited = [] visited[s_area] = 1 q = [s_area] while ! q.empty? a0 = q.shift for w0 in $areas[a0] a1 = w0[4][3] if visited[a1].nil? visited[a1] = 1 dists[a1] = dists[a0] + 1 q << a1 end end end puts dists.max end
[["-", 0, 88, 51, 267, 0, 652, 486, 742, 0, 22], ["+", 0, 88, 51, 267, 0, 652, 486, 742, 0, 22]]
4
532
2
import java.util.Scanner; public class Main { public static void main(String[] args) { int max, min; Scanner sc = new Scanner(System.in); for (int i = 0; i <= 6; i++) { max = sc.nextInt(); min = sc.nextInt(); System.out.print(max - min); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { int max, min; Scanner sc = new Scanner(System.in); for (int i = 0; i <= 6; i++) { max = sc.nextInt(); min = sc.nextInt(); System.out.println(max - min); } } }
[["-", 0, 7, 8, 196, 0, 1, 0, 492, 141, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 492, 141, 22]]
3
83
2
import java.util.Scanner; public class Main { int high; int low; int sa; public void solve() { Scanner sc = new Scanner(System.in); for (int i = 0; i < 7; i++) { high = sc.nextInt(); low = sc.nextInt(); sa = high - low; System.out.print(sa); } } public static void main(String[] args) { Main obj = new Main(); obj.solve(); } }
import java.util.Scanner; public class Main { int high; int low; int sa; public void solve() { Scanner sc = new Scanner(System.in); for (int i = 0; i < 7; i++) { high = sc.nextInt(); low = sc.nextInt(); sa = high - low; System.out.println(sa); } } public static void main(String[] args) { Main obj = new Main(); obj.solve(); } }
[["-", 0, 7, 8, 196, 0, 1, 0, 492, 141, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 492, 141, 22]]
3
112
2
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNextInt()) { for (int i = 0; i <= 6; i++) { int fir = sc.nextInt(); int sec = sc.nextInt(); System.out.println(fir = sec); } } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNextInt()) { for (int i = 0; i <= 6; i++) { int fir = sc.nextInt(); int sec = sc.nextInt(); System.out.println(fir - sec); } } } }
[["-", 0, 1, 0, 492, 3, 4, 0, 11, 17, 32], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 17, 33]]
3
90
2
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int a, b; int ans[] = new int[7]; for (int i = 1; i < 7; i++) { a = scan.nextInt(); b = scan.nextInt(); ans[i] = a - b; } for (int i = 1; i < 7; i++) { System.out.println(ans[i]); } } }
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int a, b; int ans[] = new int[7]; for (int i = 0; i < 7; i++) { a = scan.nextInt(); b = scan.nextInt(); ans[i] = a - b; } for (int i = 0; i < 7; i++) { System.out.println(ans[i]); } } }
[["-", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499], ["+", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499]]
3
119
4
#include <stdio.h> int main(void) { int a, b; int i; for (i = 0; i < 7; i++) { scanf("%d %d", &a, &b); printf("%d", a - b); } return 0; }
#include <stdio.h> int main(void) { int a, b; int i; for (i = 0; i < 7; i++) { scanf("%d %d", &a, &b); printf("%d\n", a - b); } return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
59
1
#include <stdio.h> int main() { int a1, b1, a2, b2, a3, b3, a4, b4, a5, b5, a6, b6, a7, b7, A, B, C, D, E, F, G; scanf("%d %d", &a1, &b1); scanf("%d %d\n", &a2, &b2); scanf("%d %d\n", &a3, &b3); scanf("%d %d\n", &a4, &b4); scanf("%d %d\n", &a5, &b5); scanf("%d %d\n", &a6, &b6); scanf("%d %d\n", &a7, &b7); A = a1 - b1; B = a2 - b2; C = a3 - b3; D = a4 - b4; E = a5 - b5; F = a6 - b6; G = a7 - b7; printf("%d", A); printf("%d\n", B); printf("%d\n", C); printf("%d\n", D); printf("%d\n", E); printf("%d\n", F); printf("%d\n", G); return 0; }
#include <stdio.h> int main() { int a1, b1, a2, b2, a3, b3, a4, b4, a5, b5, a6, b6, a7, b7, A, B, C, D, E, F, G; scanf("%d %d", &a1, &b1); scanf("%d %d\n", &a2, &b2); scanf("%d %d\n", &a3, &b3); scanf("%d %d\n", &a4, &b4); scanf("%d %d\n", &a5, &b5); scanf("%d %d\n", &a6, &b6); scanf("%d %d", &a7, &b7); A = a1 - b1; B = a2 - b2; C = a3 - b3; D = a4 - b4; E = a5 - b5; F = a6 - b6; G = a7 - b7; printf("%d\n", A); printf("%d\n", B); printf("%d\n", C); printf("%d\n", D); printf("%d\n", E); printf("%d\n", F); printf("%d\n", G); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
262
2
#include <stdio.h> int main(void) { int i, a, b; for (i = 0; i < 7; i++) { scanf("%d %d", &a, &b); printf("%d", a - b); } return (0); }
#include <stdio.h> int main(void) { int i, a, b; for (i = 0; i < 7; i++) { scanf("%d %d", &a, &b); printf("%d\n", a - b); } return (0); }
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
60
1
#include <stdio.h> int main(void) { int a, b, i, w; for (i = 0; i < 7; i++) { scanf("%d %d", &a, &b); w = a - b; printf("\n", w); } return 0; }
#include <stdio.h> int main(void) { int a, b, i, w; for (i = 0; i < 7; i++) { scanf("%d %d", &a, &b); w = a - b; printf("%d\n", w); } return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
64
1
#include <stdio.h> int main(void) { int i, j, k; int data[7] = {0}; int dife[7] = {0}; for (i = 0; i < 8; i++) { scanf("%d %d", &data[i], &dife[i]); printf("%d\n", data[i] - dife[i]); } return 0; }
#include <stdio.h> int main(void) { int i, j, k; int data[7] = {0}; int dife[7] = {0}; for (i = 0; i < 7; i++) { scanf("%d %d", &data[i], &dife[i]); printf("%d\n", data[i] - dife[i]); } return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
0
91
2
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int main(void) { int a, b, c, i; for (i = 0; i < 7; i++) scanf("%d %d", &a, &b); c = a + -1 * b; printf("%d\n", c); return 0; }
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int main(void) { int a, b, c, i; for (i = 0; i < 7; i++) { scanf("%d %d", &a, &b); c = a + -1 * b; printf("%d\n", c); } return 0; }
[["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]]
0
67
2
#include <stdio.h> int main(void) { int i, a, b, c[6]; for (i = 0; i <= 5; i++) { scanf("%d", &a); scanf("%d", &b); c[i] = a - b; } for (i = 0; i <= 5; i++) { printf("%d\n", c[i]); } return 0; }
#include <stdio.h> int main(void) { int i, a, b, c[7]; for (i = 0; i <= 6; i++) { scanf("%d", &a); scanf("%d", &b); c[i] = a - b; } for (i = 0; i <= 6; i++) { printf("%d\n", c[i]); } return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
0
96
6
/* {{{ Shinobu kawaii */ /* ______ __ _ __ .' ____ \ [ | (_) [ | | (___ \_| | |--. __ _ .--. .--. | |.--. __ _ _.____`. | .-. | [ | [ `.-. |/ .'`\ \| '/'`\ \[ | | | | \____) | | | | | | | | | | || \__. || \__/ | | \_/ |, \______.'[___]|__][___][___||__]'.__.'[__;.__.' '.__.'_/ */ /* }}} */ #include <bits/stdc++.h> using namespace std; // #define int long long /* cpp template {{{ */ /* short */ #define pb push_back #define mp make_pair #define print(x) cout << x << '\n' #define Fi first #define Se second /* REPmacro */ #define REPS(i, a, n) for (int i = (a); i < (n); i++) #define REP(i, n) for (int i = 0; i < (n); i++) #define RREP(i, n) for (int i = 1; i <= (n); i++) #define DEPS(i, a, n) for (int i = (a); i >= n; i--) #define DEP(i, n) for (int i = (n); i >= 0; i--) /* typedef */ typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<vector<int>> vii; typedef pair<int, int> pii; /* const */ const int INF = 999999999; const double EPS = 1e-9; const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1}; /* func */ inline bool is_uruu(int y) { return y % 4 == 0 && y % 100 != 0 || y % 400 == 0; } inline bool inside(int y, int x, int H, int W) { return y >= 0 && x >= 0 && y < H && x < W; } /* }}} */ int j, y; void dfs(int jp, int yp, string s) { if (jp > j || yp > y) return; if (jp == j && yp == y) { print(s); return; } if (jp == 5 && yp == 5) return; if (max(jp, yp) == 5 && min(jp, yp) == 3) return; if (max(jp, yp) == 6 && min(jp, yp) == 4) return; dfs(jp + 1, yp, s + "A"); dfs(jp, yp + 1, s + "B"); } signed main() { cin.tie(0); ios::sync_with_stdio(false); cin >> j >> y; dfs(0, 0, ""); return 0; }
/* {{{ Shinobu kawaii */ /* ______ __ _ __ .' ____ \ [ | (_) [ | | (___ \_| | |--. __ _ .--. .--. | |.--. __ _ _.____`. | .-. | [ | [ `.-. |/ .'`\ \| '/'`\ \[ | | | | \____) | | | | | | | | | | || \__. || \__/ | | \_/ |, \______.'[___]|__][___][___||__]'.__.'[__;.__.' '.__.'_/ */ /* }}} */ #include <bits/stdc++.h> using namespace std; // #define int long long /* cpp template {{{ */ /* short */ #define pb push_back #define mp make_pair #define print(x) cout << x << '\n' #define Fi first #define Se second /* REPmacro */ #define REPS(i, a, n) for (int i = (a); i < (n); i++) #define REP(i, n) for (int i = 0; i < (n); i++) #define RREP(i, n) for (int i = 1; i <= (n); i++) #define DEPS(i, a, n) for (int i = (a); i >= n; i--) #define DEP(i, n) for (int i = (n); i >= 0; i--) /* typedef */ typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<vector<int>> vii; typedef pair<int, int> pii; /* const */ const int INF = 999999999; const double EPS = 1e-9; const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1}; /* func */ inline bool is_uruu(int y) { return y % 4 == 0 && y % 100 != 0 || y % 400 == 0; } inline bool inside(int y, int x, int H, int W) { return y >= 0 && x >= 0 && y < H && x < W; } /* }}} */ int j, y; void dfs(int jp, int yp, string s) { if (jp > j || yp > y) return; if (jp == j && yp == y) { print(s); return; } if (jp == 5 && yp == 5) return; if (max(jp, yp) == 5 && min(jp, yp) <= 3) return; if (max(jp, yp) == 6 && min(jp, yp) == 4) return; dfs(jp + 1, yp, s + "A"); dfs(jp, yp + 1, s + "B"); } signed main() { cin.tie(0); ios::sync_with_stdio(false); cin >> j >> y; dfs(0, 0, ""); return 0; }
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 19]]
1
412
2
#include <iostream> #include <string> using namespace std; int j, y; void check(int xt, int yt, string p) { if (xt == j && yt == y) { cout << p << endl; return; } if (xt == 5 && yt <= 3 || yt == 5 && xt <= 3) return; if (xt > j || xt > y) return; check(xt + 1, yt, p + "A"); check(xt, yt + 1, p + "B"); } int main() { string ans; cin >> j >> y; check(0, 0, ans); return 0; }
#include <iostream> #include <string> using namespace std; int j, y; void check(int xt, int yt, string p) { if (xt == j && yt == y) { cout << p << endl; return; } if (xt == 5 && yt <= 3 || yt == 5 && xt <= 3) return; if (xt > j || yt > y) return; check(xt + 1, yt, p + "A"); check(xt, yt + 1, p + "B"); } int main() { cin >> j >> y; check(0, 0, ""); return 0; }
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62]]
1
136
8
#include <iostream> using namespace std; long long s[2000000], t[2000000], e[2000000], f[20000], g[20000]; int main() { int c = 0; long long n, m; cin >> n >> m; while (true) { cin >> s[c] >> t[c] >> e[c]; if (s[c] == 0 && t[c] == 0 && e[c] == 0) { break; } c++; } int l; cin >> l; for (int i = 0; i < l; i++) { for (int j = 0; j < 20000; j++) g[j] = 0; for (int j = 1; j <= m; j++) cin >> f[j]; for (int j = 0; j < c; j++) { g[s[j]] += f[t[j]] * e[j]; } for (int j = 1; j <= n; j++) { if (i >= 2) { cout << ' '; } cout << g[j]; } } return 0; }
#include <iostream> using namespace std; long long s[2000000], t[2000000], e[2000000], f[20000], g[20000]; int main() { int c = 0; long long n, m; cin >> n >> m; while (true) { cin >> s[c] >> t[c] >> e[c]; if (s[c] == 0 && t[c] == 0 && e[c] == 0) { break; } c++; } int l; cin >> l; for (int i = 0; i < l; i++) { for (int j = 0; j < 20000; j++) g[j] = 0; for (int j = 1; j <= m; j++) cin >> f[j]; for (int j = 0; j < c; j++) { g[s[j]] += f[t[j]] * e[j]; } for (int j = 1; j <= n; j++) { if (j >= 2) { cout << ' '; } cout << g[j]; } cout << endl; } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
251
6
#include <iostream> using namespace std; int N, M, L, R, s[50003], t[50003], e[50003], c[10003]; long long d[10003]; int main() { cin >> N >> M; while (true) { cin >> s[R] >> t[R] >> e[R]; s[R]--, t[R]--; if (!e[R]) break; R++; } cin >> L; for (int i = 0; i < L; i++) { for (int j = 0; j < M; j++) cin >> c[j]; for (int j = 0; j < N; j++) d[j] = 0; for (int j = 0; j < R; j++) d[s[j]] += c[t[j]] * e[j]; for (int j = 0; j < N; j++) cout << (j ? " " : "") << d[j] << endl; } }
#include <iostream> using namespace std; int N, M, L, R, s[50003], t[50003], e[50003], c[10003]; long long d[10003]; int main() { cin >> N >> M; while (true) { cin >> s[R] >> t[R] >> e[R]; s[R]--, t[R]--; if (!e[R]) break; R++; } cin >> L; for (int i = 0; i < L; i++) { for (int j = 0; j < M; j++) cin >> c[j]; for (int j = 0; j < N; j++) d[j] = 0; for (int j = 0; j < R; j++) d[s[j]] += c[t[j]] * e[j]; for (int j = 0; j < N; j++) cout << (j ? " " : "") << d[j]; cout << endl; } }
[["+", 0, 7, 8, 9, 0, 7, 8, 1, 0, 35], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 31, 22]]
1
233
2
#include <cstdio> #include <iostream> using namespace std; int main() { int n, m, l, s, t, e, cnt = 0, a[1000000][3], b[1000000]; cin >> n >> m; while (1) { scanf("%d %d %d", &s, &t, &e); if (s + t + e == 0) break; a[cnt][0] = s; a[cnt][1] = t; a[cnt][2] = e; cnt++; } cin >> l; for (int i = 0; i < l; i++) { int c[1000000] = {}; for (int j = 1; j <= m; j++) { scanf("%d", &b[j]); } for (int j = 0; j < cnt; j++) { c[a[j][0]] += a[j][2] * b[a[j][1]]; } for (int j = 1; j <= n; j++) { printf("%d", c[j]); if (j != n) printf(" "); } printf("\n"); } return 0; }
#include <cstdio> #include <iostream> using namespace std; int main() { int n, m, l, s, t, e, cnt = 0, a[100000][3], b[100000]; cin >> n >> m; while (1) { scanf("%d %d %d", &s, &t, &e); if (s + t + e == 0) break; a[cnt][0] = s; a[cnt][1] = t; a[cnt][2] = e; cnt++; } cin >> l; for (int i = 0; i < l; i++) { int c[100000] = {}; for (int j = 1; j <= m; j++) { scanf("%d", &b[j]); } for (int j = 0; j < cnt; j++) { c[a[j][0]] += a[j][2] * b[a[j][1]]; } for (int j = 1; j <= n; j++) { printf("%d", c[j]); if (j != n) printf(" "); } printf("\n"); } return 0; }
[["-", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13]]
1
272
6
#include <bits/stdc++.h> using namespace std; // int nm[10001][10001] = {0}; map<pair<int, int>, int> nm; long long c[10001]; int b[10000]; int main() { int n, m; cin >> n >> m; while (1) { int s, t, e; scanf(" %d %d %d", &s, &t, &e); if ((s + t + e) == 0) break; // nm[s][t] = e; nm[make_pair(s, t)] = e; } int l; cin >> l; pair<int, int> tmp; while (l--) { for (int i = 1; i <= m; i++) { scanf(" %d", &b[i]); } int i, j; for (i = 1; i <= n; i++) { c[i] = 0; /*for (j = 0; j < m; j++) { c[i] = c[i] + nm[i][j+1] * b[j]; }*/ } for (map<pair<int, int>, int>::iterator itr = nm.begin(); itr != nm.end(); ++itr) { tmp = itr->first; c[tmp.first] += b[tmp.second] * itr->second; // cout << "I'm hungry " << c[tmp.first] << " " << tmp.first << " " << // tmp.second << endl; } for (int i = 1; i <= n; i++) { // cout << c[i]; printf("%d", &c[i]); if (i != n) printf(" "); // cout << ' '; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; // int nm[10001][10001] = {0}; map<pair<int, int>, int> nm; long long c[10001]; int b[10000]; int main() { int n, m; cin >> n >> m; while (1) { int s, t, e; scanf(" %d %d %d", &s, &t, &e); if ((s + t + e) == 0) break; // nm[s][t] = e; nm[make_pair(s, t)] = e; } int l; cin >> l; pair<int, int> tmp; while (l--) { for (int i = 1; i <= m; i++) { scanf(" %d", &b[i]); } int i, j; for (i = 1; i <= n; i++) { c[i] = 0; /*for (j = 0; j < m; j++) { c[i] = c[i] + nm[i][j+1] * b[j]; }*/ } for (map<pair<int, int>, int>::iterator itr = nm.begin(); itr != nm.end(); ++itr) { tmp = itr->first; c[tmp.first] += b[tmp.second] * itr->second; // cout << "I'm hungry " << c[tmp.first] << " " << tmp.first << " " << // tmp.second << endl; } for (int i = 1; i <= n; i++) { // cout << c[i]; printf("%d", c[i]); if (i != n) printf(" "); // cout << ' '; } printf("\n"); } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25]]
1
298
35
#include <iostream> #include <string> using namespace std; typedef long long ll; int main() { string str[17] = {"Man", "Oku", "Cho", "kei", "Gai", "Jo", "Jou", "Ko", "Kan", "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"}; while (1) { ll num[18] = {}; int m, n; cin >> n >> m; if (n == 0 && m == 0) break; num[0] = (ll)n; for (int i = 1; i < m; i++) { for (int j = 0; j < 18; j++) num[j] *= n; for (int j = 0; j < 18; j++) if (num[j] / 10000 >= 1) num[j + 1] += num[j] / 10000, num[j] %= 10000; } for (int j = 0; j < 18; j++) if (num[j] / 10000 >= 1) num[j + 1] += num[j] / 10000, num[j] %= 10000; for (int i = 16; i >= 1; i--) if (num[i] != 0) cout << num[i] << str[i - 1]; if (num[0] != 0) cout << num[0]; cout << endl; } return 0; }
#include <iostream> #include <string> using namespace std; typedef long long ll; int main() { string str[17] = {"Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"}; while (1) { ll num[18] = {}; int m, n; cin >> n >> m; if (n == 0 && m == 0) break; num[0] = (ll)n; for (int i = 1; i < m; i++) { for (int j = 0; j < 18; j++) num[j] *= n; for (int j = 0; j < 17; j++) if (num[j] / 10000 >= 1) num[j + 1] += num[j] / 10000, num[j] %= 10000; } for (int j = 0; j < 17; j++) if (num[j] / 10000 >= 1) num[j + 1] += num[j] / 10000, num[j] %= 10000; for (int i = 17; i >= 1; i--) if (num[i] != 0) cout << num[i] << str[i - 1]; if (num[0] != 0) cout << num[0]; cout << endl; } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
332
8
unit = ['', 'Man', 'Oku', 'Cho', 'Kei', 'Gai', 'Jo', 'Jou', 'Ko', 'Kan', 'Sei', 'Sai', 'Gok', 'Ggs', 'Asg', 'Nyt', 'Fks', 'Mts'] while true a,b = gets.split() if a==0 then break end p = a.to_i**b.to_i s = '' for i in 0..17 do rem = p%10000 if rem!=0 then s = rem.to_s + unit[i] + s end p /= 10000 end puts s end
unit = ['', 'Man', 'Oku', 'Cho', 'Kei', 'Gai', 'Jo', 'Jou', 'Ko', 'Kan', 'Sei', 'Sai', 'Gok', 'Ggs', 'Asg', 'Nyt', 'Fks', 'Mts'] while true a,b = gets.split() if a=='0' then break end p = a.to_i**b.to_i s = '' for i in 0..17 do rem = p%10000 if rem!=0 then s = rem.to_s + unit[i] + s end p /= 10000 end puts s end
[["+", 8, 170, 0, 121, 15, 738, 12, 557, 0, 62]]
4
142
12
unit = ['', 'Man', 'Oku', 'Cho', 'Kei', 'Gai', 'Jo', 'Jou', 'Ko', 'Kan', 'Sei', 'Sai', 'Gok', 'Ggs', 'Asg', 'Nyt', 'Fks', 'Mts'] while 1 a,b = gets.split() if a=='0' then break end p = a.to_i**b.to_i s = '' for i in 0..17 rem = p%10000 if rem then s = rem.to_s + unit[i] + s end p /= 10000 end puts s end
unit = ['', 'Man', 'Oku', 'Cho', 'Kei', 'Gai', 'Jo', 'Jou', 'Ko', 'Kan', 'Sei', 'Sai', 'Gok', 'Ggs', 'Asg', 'Nyt', 'Fks', 'Mts'] while 1 a,b = gets.split() if a=='0' then break end p = a.to_i**b.to_i s = '' for i in 0..17 rem = p%10000 if rem!=0 then s = rem.to_s + unit[i] + s end p /= 10000 end puts s end
[["+", 0, 88, 8, 170, 0, 121, 15, 738, 17, 79], ["+", 0, 88, 8, 170, 0, 121, 15, 738, 12, 612]]
4
141
2
s = ("","Man","Oku","Cho","Kei","Gai","Jo", "Jou","Ko","Kan","Sei","Sai","Gok","Ggs", "Asg","Nyt","Fks","Mts") while True: m,n = map(int,input().split()) if m == 0 and n == 0: break ans = "" for i in range(0,len(str(m**n)),4): x = m**n//(10**i)%10000#m^n / 10^i ans = str(x) + s[i//4] + ans print(ans)
s = ("","Man","Oku","Cho","Kei","Gai","Jo", "Jou","Ko","Kan","Sei","Sai","Gok","Ggs", "Asg","Nyt","Fks","Mts") while True: m,n = map(int,input().split()) if m == 0 and n == 0: break ans = "" for i in range(0,len(str(m**n)),4): x = m**n//(10**i)%10000#m^n / 10^i if x > 0: ans = str(x) + s[i//4] + ans print(ans)
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 102]]
5
160
5
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <iostream> #include <queue> #include <utility> #include <vector> using namespace std; typedef pair<int, int> P; typedef long long ll; const int MAX_V = 10000; struct edge {}; vector<edge> G[MAX_V]; // ??§????????°INF #define INF (1 << 30) // ?¨±????????????????? #define EPS (1e-10) // 2?????????????????????????????????????????? #define EQ(a, b) (abs((a) - (b)) < EPS) int main() { cin.tie(0); ios::ios_base::sync_with_stdio(false); int D, N; while (true) { cin >> D >> N; if (D == 0 && N == 0) break; vector<int> a(N), e(N), r(N); for (int i = 0; i < N; ++i) { cin >> a[i] >> e[i] >> r[i]; } vector<vector<int>> dp(D + 1, vector<int>(101, N)); dp[D][0] = 0; for (int i = D; i >= 0; --i) { for (int j = 0; j < 101; ++j) { if (dp[i][j] == INF) continue; for (int k = 0; k < N; ++k) { if (j < r[k]) continue; int tmp_i = max(0, i - a[k]), tmp_j = min(100, j + e[k]); dp[tmp_i][tmp_j] = min(dp[tmp_i][tmp_j], dp[i][j] + 1); } } } int ans = INF; for (int i = 0; i < 101; ++i) ans = min(ans, dp[0][i]); if (ans == INF) { cout << "NA" << endl; continue; } cout << ans << endl; } }
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <iostream> #include <queue> #include <utility> #include <vector> using namespace std; typedef pair<int, int> P; typedef long long ll; const int MAX_V = 10000; struct edge {}; vector<edge> G[MAX_V]; // ??§????????°INF #define INF (1 << 30) // ?¨±????????????????? #define EPS (1e-10) // 2?????????????????????????????????????????? #define EQ(a, b) (abs((a) - (b)) < EPS) int main() { cin.tie(0); ios::ios_base::sync_with_stdio(false); int D, N; while (true) { cin >> D >> N; if (D == 0 && N == 0) break; vector<int> a(N), e(N), r(N); for (int i = 0; i < N; ++i) { cin >> a[i] >> e[i] >> r[i]; } vector<vector<int>> dp(D + 1, vector<int>(101, INF)); dp[D][0] = 0; for (int i = D; i >= 0; --i) { for (int j = 0; j < 101; ++j) { if (dp[i][j] == INF) continue; for (int k = 0; k < N; ++k) { if (j < r[k]) continue; int tmp_i = max(0, i - a[k]), tmp_j = min(100, j + e[k]); dp[tmp_i][tmp_j] = min(dp[tmp_i][tmp_j], dp[i][j] + 1); } } } int ans = INF; for (int i = 0; i < 101; ++i) ans = min(ans, dp[0][i]); if (ans == INF) { cout << "NA" << endl; continue; } cout << ans << endl; } }
[["-", 49, 50, 51, 4, 0, 2, 3, 4, 0, 22], ["+", 49, 50, 51, 4, 0, 2, 3, 4, 0, 22]]
1
397
2
#include <algorithm> #include <iostream> #define N1 101 #define N2 101 #define INF 2000000000 using namespace std; void DP(); int D, N, a[N1], e[N1], r[N1]; int dp[N1 + N1 + N1 + N1][N2], minv; int main() { while (1) { cin >> D >> N; if (D == 0 && N == 0) break; for (int i = 0; i < N; i++) cin >> a[i] >> e[i] >> r[i]; DP(); } return 0; } void DP() { for (int i = 0; i < N1 + N1; i++) { for (int j = 0; j < N2; j++) { dp[i][j] = INF; } } for (int i = 1; i < N1 + N1; i++) dp[0][i] = i - 1; for (int i = D, k = 1; i >= 0; i--, k++) dp[k][0] = i; dp[1][1] = 0; for (int i = 1; i <= D + 1; i++) { for (int j = 1; j < N2; j++) { if (dp[i][j] != INF) { for (int k = 0; k < N; k++) { if (dp[0][j] >= r[k]) { if (j + e[k] >= N2) { if (dp[i + a[k]][N2 - 1] > dp[i][j] + 1) dp[i + a[k]][N2 - 1] = dp[i][j] + 1; } else if (dp[i + a[k]][j + e[k]] > dp[i][j] + 1) dp[i + a[k]][j + e[k]] = dp[i][j] + 1; } } } } } minv = INF; for (int i = D + 1; i < N1 + N1; i++) { for (int j = 1; j < N2; j++) { minv = min(minv, dp[i][j]); } } if (minv != INF) cout << minv << endl; else cout << "NA" << endl; }
#include <algorithm> #include <iostream> #define N1 102 #define N2 102 #define INF 2000000000 using namespace std; void DP(); int D, N, a[N1], e[N1], r[N1]; int dp[N1 + N1 + N1 + N1][N2], minv; int main() { while (1) { cin >> D >> N; if (D == 0 && N == 0) break; for (int i = 0; i < N; i++) cin >> a[i] >> e[i] >> r[i]; DP(); } return 0; } void DP() { for (int i = 0; i < N1 + N1; i++) { for (int j = 0; j < N2; j++) { dp[i][j] = INF; } } for (int i = 1; i < N2; i++) dp[0][i] = i - 1; for (int i = D, k = 1; i >= 0; i--, k++) dp[k][0] = i; dp[1][1] = 0; for (int i = 1; i <= D + 1; i++) { for (int j = 1; j < N2; j++) { if (dp[i][j] != INF) { for (int k = 0; k < N; k++) { if (dp[0][j] >= r[k]) { if (j + e[k] >= N2) { if (dp[i + a[k]][N2 - 1] > dp[i][j] + 1) dp[i + a[k]][N2 - 1] = dp[i][j] + 1; } else if (dp[i + a[k]][j + e[k]] > dp[i][j] + 1) dp[i + a[k]][j + e[k]] = dp[i][j] + 1; } } } } } minv = INF; for (int i = D + 1; i < N1 + N1; i++) { for (int j = 1; j < N2; j++) { minv = min(minv, dp[i][j]); } } if (minv != INF) cout << minv << endl; else cout << "NA" << endl; }
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
527
8
#include <algorithm> #include <bitset> #include <cstdio> #include <cstdlib> #include <iostream> #include <iterator> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <string> #include <time.h> #include <vector> using namespace std; #define rep(I, N) for (int I = 0; I < (int)(N); I++) #define FIN(V) cout << V << endl #define pb push_back #define INF (1 << 30) typedef pair<int, int> P; typedef long long ll; typedef priority_queue<int> pq; int StrToInt(string); string IntToStr(int); int calc(int from, int to) { if (from == to) return 0; int T = 0; if (from % 2 != 1) { T++; from++; } if (to % 2 != 1) { T++; to--; } T += calc(from / 2, to / 2); return T; } int main(void) { /*for(int i = -16; i < 16; i++){ for(int j = i+1;j < 16; j++ ){ cout << i << " " << j << endl; } }*/ int a, from, to; cin >> a; rep(i, a) { cin >> from >> to; FIN(calc(from, to)); } return 0; } int StrToInt(string s) { stringstream ss; ss << s; int val; ss >> val; return val; } string IntToStr(int i) { stringstream ss; ss << i; return ss.str(); }
#include <algorithm> #include <bitset> #include <cstdio> #include <cstdlib> #include <iostream> #include <iterator> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <string> #include <time.h> #include <vector> using namespace std; #define rep(I, N) for (int I = 0; I < (int)(N); I++) #define FIN(V) cout << V << endl #define pb push_back #define INF (1 << 30) typedef pair<int, int> P; typedef long long ll; typedef priority_queue<int> pq; int StrToInt(string); string IntToStr(int); int calc(int from, int to) { if (from == to) return 0; int T = 0; if (from % 2 != 0) { T++; from++; } if (to % 2 != 0) { T++; to--; } T += calc(from / 2, to / 2); return T; } int main(void) { int a, from, to; cin >> a; rep(i, a) { cin >> from >> to; FIN(calc(from, to)); } return 0; } int StrToInt(string s) { stringstream ss; ss << s; int val; ss >> val; return val; } string IntToStr(int i) { stringstream ss; ss << i; return ss.str(); }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
251
4
#include <iostream> using namespace std; int n, s, d, r; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d%d", &s, &d); r = 0; while (s != d) { for (int j = 30; j >= 0; j--) { if (abs(s) % (1 << j) == 0 && s + (1 << j) <= d) s += (1 << j), r++; } } printf("%d\n", r); } return 0; }
#include <iostream> using namespace std; int n, s, d, r; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d%d", &s, &d); r = 0; while (s != d) { for (int j = 30; j >= 0; j--) { if (abs(s) % (1 << j) == 0 && s + (1 << j) <= d) { s += (1 << j), r++; break; } } } printf("%d\n", r); } return 0; }
[["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
137
4
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; int cur, ret = 0; while (1) { cur = abs(a); for (int i = 8; i >= 0; i--) { if (cur % (1 << i) == 0 && a + (1 << i) <= b) { a += (1 << i); ret++; break; } } if (a == b) { cout << ret << endl; break; } } } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; int cur, ret = 0; while (1) { cur = abs(a); for (int i = 30; i >= 0; i--) { if (cur % (1 << i) == 0 && a + (1 << i) <= b) { a += (1 << i); ret++; break; } } if (a == b) { cout << ret << endl; break; } } } }
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
135
2
#include <iostream> using namespace std; int main() { int p, m, c; cin >> p, m, c; cout << p + m + c << endl; return 0; }
#include <iostream> using namespace std; int main() { int p, m, c; cin >> p >> m >> c; cout << p + m + c << endl; return 0; }
[["-", 0, 14, 8, 9, 0, 1, 0, 34, 0, 21], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 152], ["-", 8, 9, 0, 1, 0, 34, 12, 34, 0, 21], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152]]
1
40
4
while True: try: a,b,c=map(int,input().split) print(a+b+c) except:break
while True: try: a,b,c=map(int,input().split()) print(a+b+c) except:break
[["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
32
2
for i in range(int(input())): res = 0 c,a,n = list(map(int,input().split())) res = min(n,a,c) c -= res a -= res if c >= 2 and a >= 1: cca += min(c//2,a) c -= cca*2 if c >=3: res += c//3 print(res)
for i in range(int(input())): res = 0 c,a,n = list(map(int,input().split())) res = min(n,a,c) c -= res a -= res if c >= 2 and a >= 1: cca = min(c//2,a) c -= cca*2 res += cca if c >=3: res += c//3 print(res)
[["-", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 12, 22]]
5
91
5