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
f, b, d, e, m; main(a) { for (; d = scanf("%d", &a), a; printf("%d\n", m)) for (m = 9e7; (e = d * d * d - a) < 1; d++) for (b = 0; (f = -e - b * b) >= 0;) m = fmin(d + f + b++, m); }
f, b, d, e, m; main(a) { for (; d = !scanf("%d", &a), m = a; printf("%d\n", m)) for (m = 9e7; (e = d * d * d - a) < 1; d++) for (b = 0; (f = -e - b * b) >= 0;) m = fmin(d + f + b++, m); }
[["+", 0, 7, 15, 34, 31, 11, 12, 91, 17, 111], ["+", 8, 9, 0, 7, 15, 34, 12, 11, 31, 22], ["+", 8, 9, 0, 7, 15, 34, 12, 11, 17, 32]]
0
100
3
#include <stdio.h> int main(void) { int i, e, ee, x, y, z, min; while (scanf("%d", &e), e) { min = e; for (z = 0; z * z * z <= e; z++) { ee = e - z * z * z; for (y = 0; y * y <= ee; y++) ; x = ee - y * y; if (x + y + z < min) min = x + y + z; } printf("%d...
#include <stdio.h> int main(void) { int i, e, ee, x, y, z, min; while (scanf("%d", &e), e) { min = e; for (z = 0; z * z * z <= e; z++) { ee = e - z * z * z; for (y = 0; y * y + 2 * y + 1 <= ee; y++) ; x = ee - y * y; if (x + y + z < min) min = x + y + z; } ...
[["+", 0, 7, 15, 16, 31, 16, 31, 16, 17, 72], ["+", 15, 16, 31, 16, 31, 16, 12, 16, 31, 13], ["+", 15, 16, 31, 16, 31, 16, 12, 16, 17, 48], ["+", 15, 16, 31, 16, 31, 16, 12, 16, 12, 22], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 12, 13]]
0
128
15
#include <stdio.h> int main() { int e, x, y, z, r; for (; scanf("%d", &e), e;) { r = 10000000; for (z = 0; z * z * z <= e; z++) for (y = 0; y * y <= e - z * z * z; y++) if (e - y * y - z * z * z < r) r = e - y * y - z * z * z + y + z; printf("%d\n", r); } return 0; }
#include <stdio.h> int main() { int e, x, y, z, r; for (; scanf("%d", &e), e;) { r = 10000000; for (z = 0; z * z * z <= e; z++) for (y = 0; y * y <= e - z * z * z; y++) if (e - y * y - z * z * z + y + z < r) r = e - y * y - z * z * z + y + z; printf("%d\n", r); } return 0; }
[["+", 15, 23, 0, 16, 31, 16, 31, 16, 17, 72], ["+", 15, 23, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 8, 57, 15, 23, 0, 16, 31, 16, 17, 72], ["+", 8, 57, 15, 23, 0, 16, 31, 16, 12, 22]]
0
126
4
#include <cmath> #include <iostream> using namespace std; int solve(int E) { int ans = 3000000; int x; for (int y = 0; y <= 1000; ++y) for (int z = 0; z <= 100; ++z) { x = E - y * y - z * z * z; if ((x + y + z < ans) && (x > 0)) ans = x + y + z; } return ans; } int main() { int E; ...
#include <cmath> #include <iostream> using namespace std; int solve(int E) { int ans = 3000000; int x; for (int y = 0; y <= 1000; ++y) for (int z = 0; z <= 100; ++z) { x = E - y * y - z * z * z; if ((x + y + z < ans) && (x >= 0)) ans = x + y + z; } return ans; } int main() { int E;...
[["-", 15, 339, 51, 16, 12, 23, 0, 16, 17, 47], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 20]]
1
128
2
#include <bits/stdc++.h> #define int long long using namespace std; main() { int e; while (cin >> e, e) { int ans = 1e9; for (int z = 0;; z++) { if (z * z * z > e) break; for (int y = 0;; y++) { if (z * z * z + y * y > e) break; int a = e - z * z * z + y * y; ...
#include <bits/stdc++.h> #define int long long using namespace std; main() { int e; while (cin >> e, e) { int ans = 1e9; for (int z = 0;; z++) { if (z * z * z > e) break; for (int y = 0;; y++) { if (z * z * z + y * y > e) break; int a = e - z * z * z - y * y; ...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33]]
1
120
2
// include //------------------------------------------ #include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #inclu...
// include //------------------------------------------ #include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #inclu...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
420
2
#include <algorithm> #include <iostream> using namespace std; int main() { while (true) { int e; int ans = 1e+9; cin >> e; if (e == 0) { break; } for (int z = 100; z >= 0; z--) { for (int y = 1000; y >= 0; y--) { int x; if (e >= z * z * z + y * y) { x =...
#include <algorithm> #include <iostream> using namespace std; int main() { while (true) { int e; int ans = 1e+9; cin >> e; if (e == 0) { break; } for (int z = 100; z >= 0; z--) { for (int y = 1000; y >= 0; y--) { int x; if (e >= z * z * z + y * y) { x =...
[["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
129
2
#include <cmath> #include <iostream> using namespace std; int main() { int e; while (cin >> e, e) { int ret = 1e6; for (int z = 0; z <= e; ++z) { int y = (int)pow(e - z * z * z, 1.0 / 2.0); int x = e - z * z * z - y * y; ret = min(ret, x + y + z); } cout << ret << endl; } retur...
#include <cmath> #include <iostream> using namespace std; int main() { int e; while (cin >> e, e) { int ret = 1e6; for (int z = 0; z * z * z <= e; ++z) { int y = (int)pow(e - z * z * z, 1.0 / 2.0); int x = e - z * z * z - y * y; ret = min(ret, x + y + z); } cout << ret << endl; }...
[["+", 0, 7, 15, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 7, 15, 16, 31, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 17, 48], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 12, 22]]
1
106
10
#include <algorithm> #include <iostream> using namespace std; int main() { int e; while (cin >> e, e) { int ans = 1000000000; for (int z = 0; z * z * z <= e; z++) for (int y = 0; y * y + z * z * z <= e; y++) ans = min(ans, (e - y * y * -z * z * z) + y + z); cout << ans << endl; } }
#include <algorithm> #include <iostream> using namespace std; int main() { int e; while (cin >> e, e) { int ans = 1000000000; for (int z = 0; z * z * z <= e; z++) for (int y = 0; y * y + z * z * z <= e; y++) ans = min(ans, (e - y * y - z * z * z) + y + z); cout << ans << endl; } }
[["-", 0, 16, 12, 16, 31, 16, 31, 16, 17, 48]]
1
104
19
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> using namespace std; int Bsearch(int e, int n) { // cout << n << endl; int l = 0, r = e; int i = (l + r) / 2; while (r - l >= 1) { i = (l + r) / 2; // cout << "i:" << i << endl; if (e == pow(i, n)) { // cout << "aaa:...
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> using namespace std; int Bsearch(int e, int n) { // cout << n << endl; int l = 0, r = e; int i = (l + r) / 2; while (r - l >= 1) { i = (l + r) / 2; // cout << "i:" << i << endl; if (e == pow(i, n)) { // cout << "aaa:...
[["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
258
4
#include <algorithm> #include <iostream> using namespace std; int e; int x, y, z; int main() { while (true) { cin >> e; int ans = 1000000; if (e == 0) break; for (int z = 0; z * z * z < e; z++) { for (int y = 0; y * y + z * z * z < e; y++) { x = e - y * y - z * z * z; ans =...
#include <algorithm> #include <iostream> using namespace std; int e; int x, y, z; int main() { while (true) { cin >> e; int ans = 1000000; if (e == 0) break; for (int z = 0; z * z * z <= e; z++) { for (int y = 0; y * y + z * z * z <= e; y++) { x = e - y * y - z * z * z; ans...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
124
4
#include <iostream> using namespace std; int main() { int x, y, y2, z, z3, e; while (cin >> e && e != 0) { int min = 1e6; for (y = 0; y <= 1e3; y++) { y2 = y * y; for (z = 0; z <= 1e2; z++) { z3 = z * z * z; x = e - y2 - z3; if (min > x + y + z && x > 0) { min =...
#include <iostream> using namespace std; int main() { int x, y, y2, z, z3, e; while (cin >> e && e != 0) { int min = 1e6; for (y = 0; y <= 1e3; y++) { y2 = y * y; for (z = 0; z <= 1e2; z++) { z3 = z * z * z; x = e - y2 - z3; if (min > x + y + z && x >= 0) { min ...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20]]
1
124
2
#include <iostream> using namespace std; int E; int main() { while (cin >> E) { if (E == 0) break; int min = 1000001; for (int z = 0; z * z * z < E; ++z) { for (int y = 0; y * y < E - z * z * z; ++y) { int x = E - z * z * z - y * y; if (x + y + z < min) min = x + y ...
#include <iostream> using namespace std; int E; int main() { while (cin >> E) { if (E == 0) break; int min = 100000001; for (int z = 0; z * z * z < E + 1; ++z) { for (int y = 0; y * y < E - z * z * z + 1; ++y) { int x = E - z * z * z - y * y; if (x + y + z < min) mi...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
122
6
#include <iostream> using namespace std; int main() { int e; int minimum = 10000000, n = 0; while (1) { minimum = 10000000; cin >> e; if (e == 0) break; for (int i = 0; i < 100; i++) { for (int j = 0; j < 1000; j++) { n = e - i * i * i - j * j; if (n + i + j < minimum...
#include <iostream> using namespace std; int main() { int e; int minimum = 10000000, n = 0; while (1) { minimum = 10000000; cin >> e; if (e == 0) break; for (int i = 0; i < 101; i++) { for (int j = 0; j < 1001; j++) { n = e - i * i * i - j * j; if (n + i + j < minimum...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20]]
1
123
6
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { int i, j, k, l; while (1) { int x, y, z; int e; int tmp_ans, ans; scanf("%d", &e); if (e == 0) break; tmp_ans = e; for (z = 0; z * z * z < e; z++) { for (y = 0;; y++) { x = ...
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { int i, j, k, l; while (1) { int x, y, z; int e; int tmp_ans, ans; scanf("%d", &e); if (e == 0) break; tmp_ans = e; for (z = 0; z * z * z <= e; z++) { for (y = 0;; y++) { x ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
1
155
2
#include <iostream> using namespace std; int main() { int x, y, z, e, ans; while (cin >> e && e > 0) { ans = 1000000; for (z = 0; z * z * z <= e; z++) for (y = 0; (x = e - y * y + z * z * z) >= 0; y++) if (x + y + z < ans) ans = x + y + z; cout << ans << endl; } return 0; }
#include <iostream> using namespace std; int main() { int x, y, z, e, ans; while (cin >> e && e > 0) { ans = 1000000; for (z = 0; z * z * z <= e; z++) for (y = 0; (x = e - y * y - z * z * z) >= 0; y++) if (x + y + z < ans) ans = x + y + z; cout << ans << endl; } return 0; }
[["-", 8, 7, 15, 16, 31, 23, 0, 16, 17, 72], ["+", 8, 7, 15, 16, 31, 23, 0, 16, 17, 33]]
1
110
2
#include <iostream> #include <math.h> using namespace std; int E; int solve(int e) { int mi = e; for (int z = 0; z * z * z <= e; z++) { for (int y = 0; y * y <= e; y++) { if (e - y * y - z * z * z > 0) { mi = min(mi, e - y * y - z * z * z + y + z); } } } return mi; } int min(int a, i...
#include <iostream> #include <math.h> using namespace std; int E; int solve(int e) { int mi = e; for (int z = 0; z * z * z <= e; z++) { for (int y = 0; y * y <= e; y++) { if (e - y * y - z * z * z >= 0) { mi = min(mi, e - y * y - z * z * z + y + z); } } } return mi; } int min(int a, ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
157
2
#include <cmath> #include <iostream> using namespace std; int count = 0; // count the number of iterations int solve(int E) { int ans = E; for (int y = 0; y * y <= E; ++y) for (int z = 0; z * z * z <= E; ++z) { ++count; // Minimum number of counts when the looping is minimized; loop y // a...
#include <cmath> #include <iostream> using namespace std; int count = 0; // count the number of iterations int solve(int E) { int ans = E; for (int y = 0; y * y <= E; ++y) for (int z = 0; z * z * z <= E; ++z) { // ++count; // Minimum number of counts when the looping is minimized; // loop y and z t...
[["-", 8, 7, 8, 9, 0, 1, 0, 27, 17, 29], ["-", 8, 7, 8, 9, 0, 1, 0, 27, 28, 22], ["-", 0, 7, 8, 7, 8, 9, 0, 1, 0, 35], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20]]
1
155
5
#include <iostream> using namespace std; int solve(int n) { int e = 1e6; for (int i = 0; i * i * i < e; ++i) { for (int k = 0; k * k < e - i * i * i; ++k) { e = min(e, n - i * i * i - k * k + i + k); } } return e; } int main() { int n; while (true) { cin >> n; if (n == 0) { br...
#include <iostream> using namespace std; int solve(int n) { int e = 1e6; for (int i = 0; i * i * i <= n; ++i) { for (int k = 0; k * k <= n - i * i * i; ++k) { e = min(e, n - i * i * i - k * k + i + k); } } return e; } int main() { int n; while (true) { cin >> n; if (n == 0) { ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 8, 9, 0, 7, 15, 16, ...
1
127
8
#include <iostream> using namespace std; int main() { while (1) { int e, min = 100000000, ans; cin >> e; if (e == 0) break; for (int i = 0; i * i * i < e; i++) { for (int j = 0; j * j <= e; j++) { ans = e - (i * i * i + j * j); if (min > ans + j + i && e >= ans && ans >= 0...
#include <iostream> using namespace std; int main() { while (1) { int e, min = 100000000, ans; cin >> e; if (e == 0) break; for (int i = 0; i * i * i <= e; i++) { for (int j = 0; j * j <= e; j++) { ans = e - (i * i * i + j * j); if (min > ans + j + i && e >= ans && ans >= ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
1
128
2
#include <algorithm> #include <stdio.h> using namespace std; int e; int main() { while (true) { scanf("%d", &e); if (e == 0) break; int ret = 999999999; for (int z = 0; z * z * z <= e; z++) { for (int y = 0; y * y + z * z * z <= e; y++) { ret = min(ret, e - y * y + z * z * z ...
#include <algorithm> #include <stdio.h> using namespace std; int e; int main() { while (true) { scanf("%d", &e); if (e == 0) break; int ret = 999999999; for (int z = 0; z * z * z <= e; z++) { for (int y = 0; y * y + z * z * z <= e; y++) { ret = min(ret, e - y * y - z * z * z ...
[["-", 3, 4, 0, 16, 31, 16, 31, 16, 17, 72], ["+", 3, 4, 0, 16, 31, 16, 31, 16, 17, 33]]
1
123
2
#include <bits/stdc++.h> using namespace std; #define LOG(...) fprintf(stderr, __VA_ARGS__) //#define LOG(...) #define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define EXIS...
#include <bits/stdc++.h> using namespace std; #define LOG(...) fprintf(stderr, __VA_ARGS__) //#define LOG(...) #define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define EXIS...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 8, 9, 0, 7, 8, 7, 15, 16, 17, 18], ["+", 8, 9, 0, 7, 8, 7, 15, 16, 17, 19]]
1
253
4
#include <iostream> using namespace std; const int INF = 10000003; int main() { int e; while (cin >> e) { int ans = INF; for (int i = 0; i * i * i <= e; i++) { int tmp = e - i * i * i; for (int j = 0; j * j <= tmp; j++) ans = min(ans, i + tmp - j * j + j); } cout << ans << en...
#include <iostream> using namespace std; const int INF = 10000003; int main() { int e; while (cin >> e && e) { int ans = INF; for (int i = 0; i * i * i <= e; i++) { int tmp = e - i * i * i; for (int j = 0; j * j <= tmp; j++) ans = min(ans, i + tmp - j * j + j); } cout << ans ...
[["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
1
104
2
#include <iostream> using namespace std; int main() { int e, x = 0, y = 0, z = 0, ans, n, i, j; while (1) { ans = 10000000; cin >> e; if (e == 0) break; i = 1; while (1) { if (i * i * i > e) break; i++; } i--; for (; i >= 0; i--) { n = e; n -= i...
#include <iostream> using namespace std; int main() { int e, x = 0, y = 0, z = 0, ans, n, i, j; while (1) { ans = 10000000; cin >> e; if (e == 0) break; i = 1; while (1) { if (i * i * i > e) break; i++; } i--; for (; i >= 0; i--) { n = e; n -= i...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
289
2
#include <algorithm> #include <iostream> int main() { int energy; while (std::cin >> energy, energy) { int sol = 1e+9; for (int z = 0; z * z * z < energy; z++) { for (int y = 0, yMax = energy - z * z * z; y * y < yMax; y++) { sol = std::min(sol, z + y + (energy - z * z * z - y * y)); ...
#include <algorithm> #include <iostream> int main() { int energy; while (std::cin >> energy, energy) { int sol = 1e+9; for (int z = 0; z * z * z <= energy; z++) { for (int y = 0, yMax = energy - z * z * z; y * y <= yMax; y++) { // int y = ::sqrt(energy - z * z * z); sol = std::min(s...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
120
4
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996) #include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std...
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996) #include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std...
[["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 22]]
1
306
8
#include <algorithm> #include <cmath> #include <iostream> #include <limits> #include <vector> using namespace std; int count = 0; // ?¨???¬??¨ global ?????° int solve(int E) { ::count = 0; int ans = numeric_limits<int>::max(); // ?????§??? for (int y = 0; y * y <= E; ++y) { for (int z = 0; z * z * z <= E; +...
#include <algorithm> #include <cmath> #include <iostream> #include <limits> #include <vector> using namespace std; int count = 0; // ?¨???¬??¨ global ?????° int solve(int E) { ::count = 0; int ans = numeric_limits<int>::max(); // ?????§??? for (int y = 0; y * y <= E; ++y) { for (int z = 0; z * z * z <= E; +...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
172
4
#include "bits/stdc++.h" #define REP(i, n) for (int i = 0; i < n; ++i) #define RREP(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (int i = m; i < n; ++i) #define RFOR(i, m, n) for (int i = n - 1; i >= m; --i) #define ALL(v) v.begin(), v.end() #define PB(a) push_back(a) #define INF 1000000001 #define ...
#include "bits/stdc++.h" #define REP(i, n) for (int i = 0; i < n; ++i) #define RREP(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (int i = m; i < n; ++i) #define RFOR(i, m, n) for (int i = n - 1; i >= m; --i) #define ALL(v) v.begin(), v.end() #define PB(a) push_back(a) #define INF 1000000001 #define ...
[["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["-", 0, 52, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 52, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 22], ["-", 8, 9, 0, 52, 8, 9, 0, 43, 0, 35], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
1
232
7
#include <algorithm> #include <iostream> #include <vector> using namespace std; vector<int> ans; int main() { while (1) { int e; cin >> e; if (e == 0) break; int m = 1e9; for (int i = 0; i < e; i++) { if (i * i * i > e) break; int iii = i * i * i; for (int j = 0;...
#include <algorithm> #include <iostream> #include <vector> using namespace std; vector<int> ans; int main() { while (1) { int e; cin >> e; if (e == 0) break; int m = 1e9; for (int i = 0; i < e; i++) { if (i * i * i > e) break; int iii = i * i * i; for (int j = 0;...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
181
2
#include <algorithm> #include <cmath> #include <iostream> using namespace std; int main() { int e; while (cin >> e && e > 0) { int min_sum = 100000; for (int i = 0; i <= e; i++) { int j = sqrt(e - i * i * i); int k = e - i * i * i - j * j; int temp = i + j + k; min_sum = min(temp, m...
#include <algorithm> #include <cmath> #include <iostream> using namespace std; int main() { int e; while (cin >> e && e > 0) { int min_sum = 100000; for (int i = 0; i * i * i <= e; i++) { int j = sqrt(e - i * i * i); int k = e - i * i * i - j * j; int temp = i + j + k; min_sum = min...
[["+", 0, 7, 15, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 7, 15, 16, 31, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 17, 48], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 12, 22]]
1
105
4
#include <iostream> #define FOR(i, l, n) for (int(i) = (l); (i) < (n); (i)++) #define REP(i, n) FOR(i, 0, n) using namespace std; int main() { long int x, y, z, e, m; while (cin >> e, e) { m = e; for (y = 0; y * y <= e; y++) { for (z = 0; z * z * z <= e; z++) { x = e - y * y - z * z * z; ...
#include <iostream> #define FOR(i, l, n) for (int(i) = (l); (i) < (n); (i)++) #define REP(i, n) FOR(i, 0, n) using namespace std; int main() { long int x, y, z, e, m; while (cin >> e, e) { m = e; for (y = 0; y * y <= e; y++) { for (z = 0; z * z * z + y * y <= e; z++) { x = e - y * y - z * z...
[["+", 8, 9, 0, 7, 15, 16, 31, 16, 17, 72], ["+", 0, 7, 15, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 7, 15, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 7, 15, 16, 31, 16, 12, 16, 12, 22]]
1
133
4
#include <iostream> using namespace std; int main() { while (1) { int e, x, y, z, m, min = 10000000; cin >> e; if (e == 0) { break; } for (z = 0; z * z * z < e; z++) { for (y = 0; y * y + z * z * z < e; y++) { m = e - (y * y + z * z * z) + y + z; if (m < min) { ...
#include <iostream> using namespace std; int main() { while (1) { int e, x, y, z, m, min = 10000000; cin >> e; if (e == 0) { break; } for (z = 0; z * z * z <= e; z++) { for (y = 0; y * y + z * z * z <= e; y++) { m = e - (y * y + z * z * z) + y + z; if (m < min) { ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 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
127
7
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <list> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <s...
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <list> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <s...
[["-", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 8, 9, 0, 57, 75, 76, 0, 93, 0, 94], ["-", 8, 9, 0, 57, 75, 76, 0, 93, 0, 35]]
1
331
3
#include <stdio.h> #include <vector> using namespace std; int solve(int e) { int minsum = 10000000; for (int z = 0; z * z * z <= e; z++) { for (int y = 0, lim = e - z * z * z; y * y < lim; y++) { int x = e - y * y - z * z * z; if (minsum > x + y + z) { minsum = x + y + z; } } } ...
#include <stdio.h> #include <vector> using namespace std; int solve(int e) { int minsum = 10000000; for (int z = 0; z * z * z <= e; z++) { for (int y = 0, lim = e - z * z * z; y * y <= lim; y++) { int x = e - y * y - z * z * z; if (minsum > x + y + z) { minsum = x + y + z; } } }...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
151
2
#include <cctype> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> using namespace std; int main(int argc, char const *argv[]) { int e; while (cin >> e, e) { int x, y, z; int m = 1000000; // for (int i = 0; i <= e; i++) //{ // for (int j = 0; j*j <= ...
#include <cctype> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> using namespace std; int main(int argc, char const *argv[]) { int e; while (cin >> e, e) { int x, y, z; int m = 1000000; // for (int i = 0; i <= e; i++) //{ // for (int j = 0; j*j <= ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 31, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22]]
1
141
4
#include <algorithm> #include <cmath> #include <iostream> using namespace std; int main() { int x, y, z, e; while (cin >> e) { int ret = 999999999; for (int y = 0; y * y <= e; y++) { for (int z = 0; z * z * z <= e; z++) { if (e - (y * y + z * z * z) >= 0) x = e - (y * y + z * z * z);...
#include <algorithm> #include <cmath> #include <iostream> using namespace std; int main() { int x, y, z, e; while (cin >> e, e) { int ret = 999999999; for (int y = 0; y * y <= e; y++) { for (int z = 0; z * z * z <= e; z++) { if (e - (y * y + z * z * z) >= 0) x = e - (y * y + z * z * ...
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]]
1
132
2
// include //------------------------------------------ #include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include...
// include //------------------------------------------ #include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
188
4
loop do e = gets.to_i break if e == 0 z, ans = 0, e while z**3 <= e y = Math.sqrt((e-z**3)).floor x = e - y**2 - z**3 ans = [ans, x+y+z].min z += 1 end puts m end
loop do e = gets.to_i break if e == 0 z, ans = 0, e while z**3 <= e y = Math.sqrt((e-z**3)).floor x = e - y**2 - z**3 ans = [ans, x+y+z].min z += 1 end puts ans end
[["-", 196, 737, 8, 736, 0, 652, 3, 4, 0, 22], ["+", 196, 737, 8, 736, 0, 652, 3, 4, 0, 22]]
4
72
2
#!/usr/bin/env python # -*- coding: utf-8 -*- from math import sqrt while True: e = int(input()) if e == 0: break ans = 10**9 for z in range(e): if z > e: break y = int(sqrt(e-z**3)) x = e - y ** 2 - z ** 3 ans = min(ans,x+y+i) print(ans)
#!/usr/bin/env python # -*- coding: utf-8 -*- from math import sqrt while True: e = int(input()) if e == 0: break ans = 10**9 for z in range(e): if z**3 > e: break y = int(sqrt(e-z**3)) x = e - y ** 2 - z ** 3 ans = min(ans,x+y+z) print(ans)
[["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 578], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612], ["-", 0, 662, 12, 652, 3, 4, 0, 657, 12, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 12, 22]]
5
82
4
require 'prime' require 'set' require 'tsort' include Math def max(a,b); a > b ? a : b end def min(a,b); a < b ? a : b end def swap(a,b); a, b = b, a end def gif; gets.to_i ...
require 'prime' require 'set' require 'tsort' include Math def max(a,b); a > b ? a : b end def min(a,b); a < b ? a : b end def swap(a,b); a, b = b, a end def gif; gets.to_i ...
[["-", 8, 736, 0, 755, 31, 742, 0, 738, 17, 72], ["-", 8, 736, 0, 755, 31, 742, 0, 738, 12, 612]]
4
410
2
while True: n = eval(input()) if not n: break time = [0]*86400 for i in range(n): s, t = input().split() ssec = int(s[0:2])*3600 + int(s[3:5])*60 + int(s[6:8]) tsec = int(t[0:2])*3600 + int(t[3:5])*60 + int(t[6:8]) time[ssec] += 1 time[tsec] -= 1 ans = time[0...
while True: n = eval(input()) if not n: break time = [0]*86400 for i in range(n): s, t = input().split() ssec = int(s[0:2])*3600 + int(s[3:5])*60 + int(s[6:8]) tsec = int(t[0:2])*3600 + int(t[3:5])*60 + int(t[6:8]) time[ssec] += 1 time[tsec] -= 1 ans = time[0...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 31, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 612]]
5
168
2
#include <bits/stdc++.h> using namespace std; int w, h; vector<string> feeld; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 1}; int add, id; void rec(int x, int y) { if (feeld[y][x] == 'B') { id |= 1; return; } if (feeld[y][x] == 'W') { id |= 2; return; } feeld[y][x] = '-'; add++; ...
#include <bits/stdc++.h> using namespace std; int w, h; vector<string> feeld; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; int add, id; void rec(int x, int y) { if (feeld[y][x] == 'B') { id |= 1; return; } if (feeld[y][x] == 'W') { id |= 2; return; } feeld[y][x] = '-'; add++; ...
[["-", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13]]
1
383
2
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int w, h; bool visited[64][64]; vector<string> maze; bool check(int x, int y) { return x >= 0 && x < w && y >= 0 && y < h; } int dfs(int x, int y) { if (maze[y][x] == 'B') return 1; el...
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int w, h; bool visited[64][64]; vector<string> maze; bool check(int x, int y) { return x >= 0 && x < w && y >= 0 && y < h; } int dfs(int x, int y) { if (maze[y][x] == 'B') return 1; el...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 75, 76, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 12, 13]]
1
403
4
#include <algorithm> #include <cmath> #include <cstdio> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < n; ++i) #define FOR(i, a, b) for (int i = a...
#include <algorithm> #include <cmath> #include <cstdio> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < n; ++i) #define FOR(i, a, b) for (int i = a...
[["-", 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], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
547
4
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <queue> #include <string.h> #include <string> #include <vector> using namespace std; typedef complex<double> P; #define EPS (1e-10) #define EQ(a, b) (abs((a) - (b)) < EPS) #defin...
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <queue> #include <string.h> #include <string> #include <vector> using namespace std; typedef complex<double> P; #define EPS (1e-10) #define EQ(a, b) (abs((a) - (b)) < EPS) #defin...
[["-", 0, 30, 0, 43, 49, 50, 49, 80, 49, 22], ["+", 0, 30, 0, 43, 49, 50, 49, 80, 49, 22], ["-", 0, 43, 49, 50, 51, 16, 12, 69, 28, 22], ["+", 0, 43, 49, 50, 51, 16, 12, 69, 28, 22], ["-", 15, 339, 51, 16, 12, 23, 0, 16, 17, 106], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 98], ["+", 75, 76, 0, 57, 64, 9, 0, 1, 0, 35]]
1
474
11
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) #define repb(i, a, b) for (int i = a; i >= b; i--) #define all(a) a.begin(), a.end() #define o(a) cout << a << endl #define int long long #define F first; #define S second; using namespace std; typedef pair<int, int> P; int h, w; int dy[4] = {1,...
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) #define repb(i, a, b) for (int i = a; i >= b; i--) #define all(a) a.begin(), a.end() #define o(a) cout << a << endl #define int long long #define F first; #define S second; using namespace std; typedef pair<int, int> P; int h, w; int dy[4] = {1,...
[["-", 0, 43, 49, 50, 51, 16, 31, 118, 119, 120], ["+", 0, 43, 49, 50, 51, 16, 31, 118, 119, 120]]
1
500
4
#include <algorithm> #include <cstdio> #include <cstring> #include <string> #include <vector> using namespace std; #define I(n, m) \ if (find(v.begin(), v.end(), make_pair(n, m)) == v.end()) \ ret |= D(n, m, v); typedef vector<pair...
#include <algorithm> #include <cstdio> #include <cstring> #include <string> #include <vector> using namespace std; #define I(n, m) \ if (find(v.begin(), v.end(), make_pair(n, m)) == v.end()) \ ret |= D(n, m, v); typedef vector<pair...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
428
2
import sys sys.setrecursionlimit(3000) def dfs(r, c, n): board[r][c] = n drc = [(-1, 0), (0, 1), (1, 0), (0, -1)] for dr, dc in drc: nr, nc = r + dr, c + dc if 0 <= nr < h and 0 <= nc < w and board[nr][nc] != n: if board[nr][nc] in 'WB': pile.append(board[nr][nc])...
import sys sys.setrecursionlimit(3000) def dfs(r, c, n): board[r][c] = n drc = [(-1, 0), (0, 1), (1, 0), (0, -1)] for dr, dc in drc: nr, nc = r + dr, c + dc if 0 <= nr < h and 0 <= nc < w and board[nr][nc] != n: if board[nr][nc] in 'WB': pile.append(board[nr][nc])...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
337
4
import sys from collections import Counter sys.set_coroutine_wrapper(2500) def paint(field, i, j, b, f, moves={(-1, 0), (1, 0), (0, 1), (0, -1)}): fij = field[i][j] if fij & f: return if fij & 4 and not fij & b: return field[i][j] |= b | f for di, dj in moves: ni = i + di ...
import sys from collections import Counter sys.setrecursionlimit(2502) def paint(field, i, j, b, f, moves={(-1, 0), (1, 0), (0, 1), (0, -1)}): fij = field[i][j] if fij & f: return if fij & 4 and not fij & b: return field[i][j] |= b | f for di, dj in moves: ni = i + di ...
[["-", 0, 656, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 319, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 612]]
5
340
4
#include <iostream> #include <vector> #define MAX 100000 #include <bits/stdc++.h> using namespace std; int main() { int N, M; int w[1500], h[1500]; // int x[MAX]={0}; while ((cin >> N) && (cin >> M)) { int tt = 0; // w.resize(M); // h.resize(N); for (int i = 0; i < N; i++) { cin >> h[i]; ...
#include <iostream> #include <vector> #define MAX 100000 #include <bits/stdc++.h> using namespace std; int main() { int N, M; int w[1500], h[1500]; // int x[MAX]={0}; while ((cin >> N >> M) && N) { int tt = 0; // w.resize(M); // h.resize(N); for (int i = 0; i < N; i++) { cin >> h[i]; ...
[["-", 0, 52, 15, 339, 51, 16, 31, 23, 0, 25], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["-", 0, 52, 15, 339, 51, 16, 12, 23, 0, 24], ["-", 15, 339, 51, 16, 12, 23, 0, 16, 31, 22], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
1
269
6
#include <bits/stdc++.h> using namespace std; typedef ostringstream OSS; typedef istringstream ISS; typedef long long LL; typedef pair<int, int> PII; typedef pair<LL, LL> PLL; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<VVLL...
#include <bits/stdc++.h> using namespace std; typedef ostringstream OSS; typedef istringstream ISS; typedef long long LL; typedef pair<int, int> PII; typedef pair<LL, LL> PLL; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<VVLL...
[["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22]]
1
756
2
#include <algorithm> #include <iostream> using namespace std; int X[1500001] = {}, Y[1500001] = {}; int main() { int w, h; while (cin >> w >> h) { if (w == 0 && h == 0) break; int ans = 0; int x[1501] = {}, y[1501] = {}; for (int i = 0; i < h; i++) cin >> y[i]; for (int i = 0; i...
#include <algorithm> #include <iostream> using namespace std; int X[1500001] = {}, Y[1500001] = {}; int main() { int w, h; while (cin >> h >> w) { if (w == 0 && h == 0) break; int ans = 0; int x[1501] = {}, y[1501] = {}; for (int i = 0; i < h; i++) cin >> y[i]; for (int i = 0; i...
[["-", 0, 52, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 152], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 152], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
1
289
4
#include <iostream> using namespace std; int max(int a, int b) { if (a >= b) return a; else return b; } int main() { int n, m; while (cin >> n >> m) { if (n == 0 && m == 0) break; int *h, *w; int *hNum, *wNum; h = new int[n]; w = new int[m]; int maxHLength = 0; ...
#include <iostream> using namespace std; int max(int a, int b) { if (a >= b) return b; else return a; } int main() { int n, m; while (cin >> n >> m) { if (n == 0 && m == 0) break; int *h, *w; int *hNum, *wNum; h = new int[n]; w = new int[m]; int maxHLength = 0; ...
[["-", 0, 14, 8, 9, 0, 57, 64, 37, 0, 22], ["+", 0, 14, 8, 9, 0, 57, 64, 37, 0, 22], ["-", 8, 9, 0, 57, 75, 76, 0, 37, 0, 22], ["+", 8, 9, 0, 57, 75, 76, 0, 37, 0, 22]]
1
385
4
#include "bits/stdc++.h" using namespace std; int main() { int n, flag = 0; while (cin >> n, n) { if (flag) cout << endl; int m[4], c[4] = {10, 50, 100, 500}, k[4] = {}; for (int i = 0; i < 4; ++i) { cin >> m[i]; } for (int i = 0; i < 4; ++i) { n -= m[i] * c[i]; k[i] +=...
#include "bits/stdc++.h" using namespace std; int main() { int n, flag = 0; while (cin >> n, n) { if (flag) cout << endl; int m[4], c[4] = {10, 50, 100, 500}, k[4] = {}; for (int i = 0; i < 4; ++i) { cin >> m[i]; } for (int i = 0; i < 4; ++i) { n -= m[i] * c[i]; k[i] +=...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
287
6
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using vs = vector<string>; using msi = map<string, int>; using mii = map<int, int>; using pii = pair<int, int>; using vlai = valarray<int>; using ll = long long; #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n)...
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using vs = vector<string>; using msi = map<string, int>; using mii = map<int, int>; using pii = pair<int, int>; using vlai = valarray<int>; using ll = long long; #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n)...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
320
2
#include <algorithm> #include <ciso646> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; const ll MOD = 1000000007; const ll INF = (ll)1000000007 *...
#include <algorithm> #include <ciso646> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; const ll MOD = 1000000007; const ll INF = (ll)1000000007 *...
[["-", 64, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 64, 1, 0, 16, 31, 16, 12, 69, 28, 22]]
1
379
8
#include <cstdio> #include <iostream> using namespace std; enum coins { ten = 0, fifty, hundred, five_hundred, coin_max }; const int kcoin[coin_max] = {10, 50, 100, 500}; int M; int min_nums; int ans_nums[coin_max]; int nums[coin_max]; int tans_nums[coin_max]; int minimumExchange(int m, int *nums) { int t = 0; ...
#include <cstdio> #include <iostream> using namespace std; enum coins { ten = 0, fifty, hundred, five_hundred, coin_max }; const int kcoin[coin_max] = {10, 50, 100, 500}; int M; int min_nums; int ans_nums[coin_max]; int nums[coin_max]; int tans_nums[coin_max]; int minimumExchange(int m, int *nums) { int t = 0; ...
[["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 0, 52, 8, 9, 0, 57, 64, 9, 0, 46]]
1
621
2
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include...
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include...
[["+", 0, 11, 31, 69, 341, 342, 0, 16, 31, 13], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 17, 33]]
1
272
2
#include <stdio.h> int main() { int a; int k = 0; while (scanf("%d", &a), a) { if (k) printf("\n"); k = 1; int b, c, d, e; scanf("%d%d%d%d", &b, &c, &d, &e); int rb = 0, rc = 0, rd = 0, re = 0, min = 999999; for (int i = 0; i <= b; i++) for (int j = 0; j <= c; j++) for ...
#include <stdio.h> int main() { int a; int k = 0; while (scanf("%d", &a), a) { if (k) printf("\n"); k = 1; int b, c, d, e; scanf("%d%d%d%d", &b, &c, &d, &e); int rb = 0, rc = 0, rd = 0, re = 0, min = 999999; for (int i = 0; i <= b; i++) for (int j = 0; j <= c; j++) for ...
[["-", 15, 339, 51, 16, 12, 16, 31, 16, 17, 109], ["-", 15, 339, 51, 16, 12, 16, 31, 16, 12, 13], ["-", 31, 16, 31, 16, 12, 16, 31, 16, 17, 109], ["-", 31, 16, 31, 16, 12, 16, 31, 16, 12, 13]]
1
391
6
#include <cstring> #include <iostream> #define rep(i, n) for (int i = 0; i < n; i++) int main() { int m, c[4], p[4], r[4]; int d[4] = {10, 50, 100, 500}; bool firstline = true; while (std::cin >> m, (m)) { if (!firstline) { std::cout << std::endl; } firstline = false; rep(i, 4) { std:...
#include <cstring> #include <iostream> #define rep(i, n) for (int i = 0; i < n; i++) int main() { int m, c[4], p[4], r[4]; int d[4] = {10, 50, 100, 500}; bool firstline = true; while (std::cin >> m, (m)) { if (!firstline) { std::cout << std::endl; } firstline = false; rep(i, 4) { std:...
[["+", 0, 11, 12, 69, 341, 342, 0, 16, 31, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 27, 28, 69, 341, 342, 0, 16, 31, 13], ["+", 0, 27, 28, 69, 341, 342, 0, 16, 17, 33]]
1
438
4
#include <iostream> using namespace std; #define INF 1 << 28 int p; int n[4]; int v[4] = {10, 50, 100, 500}; int count_coin(int a, int b, int c, int d) { int sum = v[0] * a + v[1] * b + v[2] * c + v[3] * d - p; if (sum < 0) return INF; int change = 0; for (int i = 3; i >= 0; i--) { int t = sum / v[i...
#include <iostream> using namespace std; #define INF 1 << 28 int p; int n[4]; int v[4] = {10, 50, 100, 500}; int count_coin(int a, int b, int c, int d) { int sum = v[0] * a + v[1] * b + v[2] * c + v[3] * d - p; if (sum < 0) return INF; int change = 0; for (int i = 3; i >= 0; i--) { int t = sum / v[i...
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 17, 72], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 33], ["+", 8, 9, 0, 37, 0, 16, 12, 23, 0, 24], ["+", 8, 9, 0, 37, 0, 16, 12, 23, 0, 25]]
1
427
4
#include <cassert> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <sstream> #include <stack> #include <vector> #define all(n) n.begin(), n.end() ...
#include <cassert> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <sstream> #include <stack> #include <vector> #define all(n) n.begin(), n.end() ...
[["-", 49, 50, 51, 2, 3, 4, 0, 69, 28, 22], ["+", 49, 50, 51, 2, 3, 4, 0, 69, 28, 22]]
1
594
2
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; int n; int c[] = {10, 50, 100, 500}; int k[4]; int a[4]; int main(void) { bool f = false; while (cin >> n) { if (!n) break; if (f) cout << endl; f = true; memset(a, 0, siz...
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; int n; int c[] = {10, 50, 100, 500}; int k[4]; int a[4]; int main(void) { bool f = false; while (cin >> n) { if (!n) break; if (f) cout << endl; f = true; memset(a, 0, siz...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 0, 1, 0, 11, 12, 16, 12, 69, 28, 22], ["+", 0, 11, 12, 16, 12, 69, 341, 342, 0, 70], ["+", 0, 11, 12, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 11, 12, 16, 12, 69, 341, 342, 0, 73]]
1
232
5
#include <iostream> #include <vector> using namespace std; int main() { int n; int TYPE[5] = {10, 50, 100, 500, 1000}; vector<int> vec; int firstFlag = 0; while (true) { cin >> n; if (n == 0) break; if (firstFlag == 0) { firstFlag = 1; } else { cout << endl; } vec = v...
#include <iostream> #include <vector> using namespace std; int main() { int n; int TYPE[5] = {10, 50, 100, 500, 1000}; vector<int> vec; int firstFlag = 0; while (true) { cin >> n; if (n == 0) break; if (firstFlag == 0) { firstFlag = 1; } else { cout << endl; } vec = v...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
276
18
def f(x) k = 0 k += x / 500 x %= 500 k += x / 100 x %= 100 k += x / 50 x %= 50 k + x / 10 end ans = [] loop { price = gets.to_i break if price == 0 a, b, c, d = gets.split.map &:to_i min = Float::INFINITY min_by = nil (0..a).each{|x| (0..b).each{|y| (0..c).each{|z| (0..d).each{|w| total = 10*x+50*y...
def f(x) k = 0 k += x / 500 x %= 500 k += x / 100 x %= 100 k += x / 50 x %= 50 k + x / 10 end ans = [] loop { price = gets.to_i break if price == 0 a, b, c, d = gets.split.map &:to_i min = Float::INFINITY min_by = nil (0..a).each{|x| (0..b).each{|y| (0..c).each{|z| (0..d).each{|w| total = 10*x+50*y...
[["+", 196, 196, 8, 734, 0, 738, 12, 652, 17, 131], ["+", 196, 196, 8, 734, 0, 738, 12, 652, 735, 22]]
4
243
2
#include <cmath> #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < n; i++) #define EPS 1e-8 int n, hx, hy, dx, dy; int x[30], y[30]; bool flag; void dfs(int unvisit, int cx, int cy, double t) { if (flag) return; if (unvisit == 0) flag = true; else { ...
#include <cmath> #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < n; i++) #define EPS 1e-8 int n, hx, hy, dx, dy; int x[30], y[30]; bool flag; void dfs(int unvisit, int cx, int cy, double t) { if (flag) return; if (unvisit == 0) flag = true; else { ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
306
2
loop { n, hx, hy, dx, dy = gets.split.map &:to_i break if n == 0 points = [[hx, hy]] + (1..n).map { gets.split.map &:to_i } dist = (0..n).map{|i| (0..n).map{|j| x1, y1 = points[i] x2, y2 = points[j] sqrt((x1-x2)**2 + (y1-y2)**2) } } deadline...
include Math loop { n, hx, hy, dx, dy = gets.split.map &:to_i break if n == 0 points = [[hx, hy]] + (1..n).map { gets.split.map &:to_i } dist = (0..n).map{|i| (0..n).map{|j| x1, y1 = points[i] x2, y2 = points[j] sqrt((x1-x2)**2 + (y1-y2)**2) } }...
[["+", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["+", 36, 36, 0, 493, 0, 652, 3, 4, 0, 743]]
4
252
26
#include <cstdio> #pragma warning(disable : 4996) #define MAX_N 1500 #define MAX_D 1000 #define MAX_R MAX_N *MAX_D int N, M, H[MAX_N], W[MAX_N]; int dp[2][MAX_R + 1]; int main() { while (true) { scanf("%d", &N); scanf("%d", &M); if (N == 0 && M == 0) { break; } for (int i = 0; i < N;...
#include <cstdio> #pragma warning(disable : 4996) #define MAX_N 1500 #define MAX_D 1000 #define MAX_R MAX_N *MAX_D int N, M, H[MAX_N], W[MAX_N]; int dp[2][MAX_R + 1]; int main() { while (true) { scanf("%d", &N); scanf("%d", &M); if (N == 0 && M == 0) { break; } for (int i = 0; i < N;...
[["-", 8, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 69, 28, 22]]
1
323
2
#include <iostream> using namespace std; const int MAX_N = 1500, MAX_M = 1500, MAX_W = 1000; int roadV[MAX_N], roadH[MAX_M]; int widthV[MAX_N * MAX_W + 1]; int widthH[MAX_M * MAX_W + 1]; inline int min(int a, int b) { if (a < b) return a; return b; } int main() { ios_base::sync_with_stdio(0); int n, m, i...
#include <iostream> using namespace std; const int MAX_N = 1500, MAX_M = 1500, MAX_W = 1000; int roadV[MAX_N], roadH[MAX_M]; int widthV[MAX_N * MAX_W + 1]; int widthH[MAX_M * MAX_W + 1]; inline int min(int a, int b) { if (a < b) return a; return b; } int main() { ios_base::sync_with_stdio(0); int n, m, i...
[["-", 8, 9, 0, 1, 0, 27, 28, 69, 28, 22], ["+", 8, 9, 0, 1, 0, 27, 28, 69, 28, 22]]
1
382
2
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <set> #include <string.h> #include <vector> #define pb push_back using namespace std; int n, m; int mitih[1500000], mitiw[1500000]; int main(void) { int i, j, x, tmp, res; vector<int> h, w; while (scanf("%d %d", &n, &m), n | m) {...
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <set> #include <string.h> #include <vector> #define pb push_back using namespace std; int n, m; int mitih[1500000], mitiw[1500000]; int main(void) { int i, j, x, tmp, res; vector<int> h, w; while (scanf("%d %d", &n, &m), n | m) {...
[["-", 0, 7, 15, 16, 12, 2, 63, 118, 28, 22], ["+", 0, 7, 15, 16, 12, 2, 63, 118, 28, 22]]
1
466
2
#include <iostream> #include <unordered_map> #include <vector> using namespace std; int main() { while (1) { int n, m; cin >> n >> m; if (n == 0) break; vector<int> h(n), w(m); for (int i = 0; i < n; i++) { cin >> h[i]; } for (int i = 0; i < m; i++) { cin >> w[i]; }...
#include <iostream> #include <unordered_map> #include <vector> using namespace std; int main() { while (1) { int n, m; cin >> n >> m; if (n == 0) break; vector<int> h(n), w(m); for (int i = 0; i < n; i++) { cin >> h[i]; } for (int i = 0; i < m; i++) { cin >> w[i]; }...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22]]
1
314
4
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define fi first #define se second #define fcout(n) cout << fixed << setprecision((n...
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define fi first #define se second #define fcout(n) cout << fixed << setprecision((n...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 31, 22], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
565
4
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for (int i = 0; i < (n); i++) #define REP2(i, m, n) for (int i = m; i < (n); i++) const int MAX = 1500 * 1000 + 1; int N, M; int H[2020]; int W[2020]; ll A[MAX]; ll B[MAX]; bool solve() { cin >> N >> M; REP(i, N) cin >> H[i]; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for (int i = 0; i < (n); i++) #define REP2(i, m, n) for (int i = m; i < (n); i++) const int MAX = 1500 * 1000 + 1; int N, M; int H[2020]; int W[2020]; ll A[MAX]; ll B[MAX]; bool solve() { cin >> N >> M; REP(i, N) cin >> H[i]; ...
[["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22]]
1
262
4
// clang-format off #include <bits/stdc++.h> using namespace std; #define int long long #define main signed main() #define loop(i, a, n) for (int i = (a); i < (n); i++) #define rep(i, n) loop(i, 0, n) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define prec(n) fixed << setprecision(n)...
// clang-format off #include <bits/stdc++.h> using namespace std; #define int long long #define main signed main() #define loop(i, a, n) for (int i = (a); i < (n); i++) #define rep(i, n) loop(i, 0, n) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define prec(n) fixed << setprecision(n)...
[["-", 0, 2, 3, 4, 0, 16, 31, 16, 31, 22], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 31, 13]]
1
771
4
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define out(S) cout << (S) << endl; #define ShowAll(collection) \ for (auto i : collection) { \ out(i); ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define out(S) cout << (S) << endl; #define ShowAll(collection) \ for (auto i : collection) { \ out(i); ...
[["-", 31, 2, 3, 4, 0, 16, 31, 2, 63, 22], ["+", 31, 2, 3, 4, 0, 16, 31, 2, 63, 22]]
1
390
2
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <utility> #include <vector> #define int long long int #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef pair<int, int> P; const int INF = 1e15; const int MO...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <utility> #include <vector> #define int long long int #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef pair<int, int> P; const int INF = 1e15; const int MO...
[["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22]]
1
463
4
#include <iostream> #include <string.h> using namespace std; int num[2000 * 1500]; int main() { int N, M; while (cin >> N >> M && N != 0) { memset(num, 0, sizeof(num)); int h[1501], w[1501]; h[0] = w[0] = 0; for (int i = 1; i <= N; i++) { cin >> h[i]; h[i] += h[i - 1]; } for ...
#include <iostream> #include <string.h> using namespace std; int num[2000 * 1500]; int main() { int N, M; while (cin >> N >> M && N != 0) { memset(num, 0, sizeof(num)); int h[1501], w[1501]; h[0] = w[0] = 0; for (int i = 1; i <= N; i++) { cin >> h[i]; h[i] += h[i - 1]; } for ...
[["-", 341, 342, 0, 16, 31, 69, 341, 342, 0, 22], ["+", 341, 342, 0, 16, 31, 69, 341, 342, 0, 22], ["-", 341, 342, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 341, 342, 0, 16, 12, 69, 341, 342, 0, 22]]
1
257
8
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { for (int N, M; cin >> N >> M, N + M == 0;) { vector<int> H(N + 1); vector<int> W(M + 1); H[0] = W[0] = 0; for (int i = 1; i <= N; i++) { int k; cin >> k; H[i] = H[i - 1] + k; } for (...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { for (int N, M; cin >> N >> M, N + M != 0;) { vector<int> H(N + 1); vector<int> W(M + 1); H[0] = W[0] = 0; for (int i = 1; i <= N; i++) { int k; cin >> k; H[i] = H[i - 1] + k; } for (...
[["-", 8, 9, 0, 7, 15, 34, 12, 16, 17, 60], ["+", 8, 9, 0, 7, 15, 34, 12, 16, 17, 79]]
1
390
2
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main(int argc, char const *argv[]) { while (1) { int n, m; cin >> n >> m; vector<int> hmap, wmap; vector<int> map; if (!n || !m) return 0; int o = 0; for (int i = 0; i < n; i++) { int h; ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main(int argc, char const *argv[]) { while (1) { int n, m; cin >> n >> m; vector<int> hmap, wmap; vector<int> map; if (!n || !m) return 0; int o = 0; for (int i = 0; i < n; i++) { int h; ...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 7, 8, 9, 0, 1, 0, 27, 17, 29]]
1
306
5
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, j) FOR(i, 0, j) #define mp std::make_pair const int INF = 1 << 24; const int dx[8] = {0, 0, ...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, j) FOR(i, 0, j) #define mp std::make_pair const int INF = 1 << 24; const int dx[8] = {0, 0, ...
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
335
6
loop { n, m = gets.split.map &:to_i break if n == 0 hs = (1..n).map { gets.to_i } ws = (1..m).map { gets.to_i } h_hash = Hash.new(0) (0..hs.size-1).each{|i| s = 0 (i..hs.size-1).each{|j| s += hs[j] h_hash[s] += 1 } } w_hash = Hash.new(0) (0..ws.size-1).each{|i| s = 0 (i..ws.size-1).each{|j| ...
loop { n, m = gets.split.map &:to_i break if n == 0 hs = (1..n).map { gets.to_i } ws = (1..m).map { gets.to_i } h_hash = Hash.new(0) (0..hs.size-1).each{|i| s = 0 (i..hs.size-1).each{|j| s += hs[j] h_hash[s] += 1 } } w_hash = Hash.new(0) (0..ws.size-1).each{|i| s = 0 (i..ws.size-1).each{|j| ...
[["-", 0, 755, 12, 738, 12, 742, 500, 742, 0, 22], ["+", 0, 755, 12, 738, 12, 742, 500, 742, 0, 22]]
4
266
2
#include <iostream> #include <numeric> #include <vector> using namespace std; int main() { while (true) { // N, M, P ?????\??? int n, m, p; cin >> n >> m >> p; // 0 0 0 ???????????? if (n == 0 && m == 0 && p == 0) return 0; // x ?????\??? vector<int> x(n); for (auto &a : x) ...
#include <iostream> #include <numeric> #include <vector> using namespace std; int main() { while (true) { // N, M, P ?????\??? int n, m, p; cin >> n >> m >> p; // 0 0 0 ???????????? if (n == 0 && m == 0 && p == 0) return 0; // x ?????\??? vector<int> x(n); for (auto &a : x) ...
[["-", 51, 16, 31, 69, 341, 342, 0, 16, 31, 22], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 31, 22]]
1
159
2
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m, p; while (cin >> n >> m >> p && (n || m == 0 || p == 0)) { int sum = 0; int maisu = 0; int winner = -1; for (int i = 0; i < n; i++) { cin >> m...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m, p; while (cin >> n >> m >> p && (n || m || p)) { int sum = 0; int maisu = 0; int winner = -1; for (int i = 0; i < n; i++) { cin >> maisu; ...
[["-", 12, 23, 0, 16, 31, 16, 12, 16, 17, 60], ["-", 12, 23, 0, 16, 31, 16, 12, 16, 12, 13], ["-", 51, 16, 12, 23, 0, 16, 12, 16, 17, 60], ["-", 51, 16, 12, 23, 0, 16, 12, 16, 12, 13]]
1
160
4
#include <iostream> using namespace std; int main() { int n, m, p; while (cin >> n >> m >> p, n, m, p) { int sum = 0; int key; for (int i = 1; i <= n; i++) { int k; cin >> k; sum += k; if (i == m) key = k; } if (key == 0) cout << "0\n"; else cout <...
#include <iostream> using namespace std; int main() { int n, m, p; while (cin >> n >> m >> p, n || m || p) { int sum = 0; int key; for (int i = 1; i <= n; i++) { int k; cin >> k; sum += k; if (i == m) key = k; } if (key == 0) cout << "0\n"; else co...
[["-", 0, 52, 15, 339, 51, 34, 12, 34, 0, 21], ["+", 15, 339, 51, 34, 12, 16, 31, 16, 17, 106], ["-", 15, 339, 51, 34, 12, 34, 12, 34, 0, 21], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 106]]
1
110
4
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using vs = vector<string>; #define rep(i, n) for (int i = 0; i < n; i++) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() int main(void) { int n, m, p; while (cin >> n >> m >> p, n) { double t = ...
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using vs = vector<string>; #define rep(i, n) for (int i = 0; i < n; i++) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() int main(void) { int n, m, p; while (cin >> n >> m >> p, n) { double t = ...
[["+", 0, 41, 64, 16, 31, 16, 12, 23, 0, 24], ["+", 64, 16, 31, 16, 12, 23, 0, 16, 31, 13], ["+", 64, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 41, 64, 16, 31, 16, 12, 23, 0, 25]]
1
135
4
#include <bits/stdc++.h> using namespace std; void solve(int n, int m, int p) { vector<int> v; int a; int sum = 0; for (int i = 0; i < n; i++) { cin >> a; sum += a; v.push_back(a); } if (v[m - 1]) cout << (sum * p / v[m - 1]) << endl; else cout << 0 << endl; } int main(void) { int ...
#include <bits/stdc++.h> using namespace std; void solve(int n, int m, int p) { vector<int> v; int a; int sum = 0; for (int i = 0; i < n; i++) { cin >> a; sum += a; v.push_back(a); } if (v[m - 1]) cout << (sum * (100 - p) / v[m - 1]) << endl; else cout << 0 << endl; } int main(void) ...
[["+", 12, 23, 0, 16, 31, 16, 12, 23, 0, 24], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 31, 13], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 12, 23, 0, 16, 31, 16, 12, 23, 0, 25]]
1
135
4
#include "bits/stdc++.h" using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m, p; while (cin >> n >> m >> p, n && m && p) { int su = 0; vector<int> x(n); for (int i = 0; i < n; i++) { cin >> x[i]; su += x[i]; } m--; if (x[m] == 0) cout ...
#include "bits/stdc++.h" using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m, p; while (cin >> n >> m >> p, n || m || p) { int su = 0; vector<int> x(n); for (int i = 0; i < n; i++) { cin >> x[i]; su += x[i]; } m--; if (x[m] == 0) cout ...
[["-", 15, 339, 51, 34, 12, 16, 31, 16, 17, 98], ["+", 15, 339, 51, 34, 12, 16, 31, 16, 17, 106], ["-", 0, 52, 15, 339, 51, 34, 12, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 106]]
1
135
4
#include <iostream> using namespace std; int main() { int n, m, p, a, v, sum = 0; while (1) { cin >> n >> m >> p; if (n == 0 && m == 0 && p == 0) break; for (int i = 1; i <= n; i++) { cin >> a; sum += a; if (i == m) v = a; } if (v == 0) cout << "0\n"; ...
#include <iostream> using namespace std; int main() { int n, m, p, a, v, sum = 0; while (1) { cin >> n >> m >> p; if (n == 0 && m == 0 && p == 0) break; for (int i = 1; i <= n; i++) { cin >> a; sum += a; if (i == m) v = a; } if (v == 0) cout << "0\n"; ...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
124
4
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n, m, p; while (cin >> n >> m >> p, n || m || p) { vector<int> x(n); int bet = 0; for (int i = 0; i < n; i++) { // input cin >> x[i]; bet += x[i]; } bet = bet * p; if (x[m - 1] ==...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n, m, p; while (cin >> n >> m >> p, n || m || p) { vector<int> x(n); int bet = 0; for (int i = 0; i < n; i++) { // input cin >> x[i]; bet += x[i]; } bet = bet * (100 - p); if (x[m...
[["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 31, 13], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
1
138
4
#include <algorithm> #include <iostream> #include <math.h> #include <numeric> #include <string> #include <vector> using namespace std; int N, M, P; int main() { while (cin >> N >> M >> P, N && M && P) { int sum = 0, temp = 0; for (int i = 0; i < N; ++i) { int a; cin >> a; if (i == M - 1) ...
#include <algorithm> #include <iostream> #include <math.h> #include <numeric> #include <string> #include <vector> using namespace std; int N, M, P; int main() { while (cin >> N >> M >> P, N || M || P) { int sum = 0, temp = 0; for (int i = 0; i < N; ++i) { int a; cin >> a; if (i == M - 1) ...
[["-", 15, 339, 51, 34, 12, 16, 31, 16, 17, 98], ["+", 15, 339, 51, 34, 12, 16, 31, 16, 17, 106], ["-", 0, 52, 15, 339, 51, 34, 12, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 106]]
1
129
4
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <ut...
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <ut...
[["-", 0, 52, 15, 339, 51, 34, 12, 34, 0, 21], ["-", 15, 339, 51, 34, 12, 34, 12, 34, 31, 22], ["-", 15, 339, 51, 34, 12, 34, 12, 34, 0, 21], ["-", 15, 339, 51, 34, 12, 34, 12, 34, 12, 22]]
1
291
4
#include <stdio.h> int main(void) { double sum; int n, m, p, i, x[100]; while (1) { scanf("%d%d%d", &n, &m, &p); if (n == 0 && m == 0 && p == 0) break; sum = 0; for (i = 0; i < n; i++) { scanf("%d", &x[i]); sum += 100 * x[i]; } if (x[m - 1] == 0) { sum = sum * (100...
#include <stdio.h> int main(void) { double sum; int n, m, p, i, x[100]; while (1) { scanf("%d%d%d", &n, &m, &p); if (n == 0 && m == 0 && p == 0) break; sum = 0; for (i = 0; i < n; i++) { scanf("%d", &x[i]); sum += 100 * x[i]; } if (x[m - 1] != 0) { sum = sum * (100...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79]]
1
164
2
#include <iostream> using namespace std; int main() { int n, m, p, ans; while (1) { cin >> n >> m >> p; if (n == 0 && m == 0 && p == 0) break; ans = 0; for (int i = 1; i <= n; i++) { int x; cin >> x; ans += x; if (i == m) m = x; } if (m == 0) { ...
#include <iostream> using namespace std; int main() { int n, m, p, ans; while (1) { cin >> n >> m >> p; if (n == 0 && m == 0 && p == 0) break; ans = 0; int a; for (int i = 1; i <= n; i++) { int x; cin >> x; ans += x; if (i == m) a = x; } if (a == ...
[["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 49, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 0, 35], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 0, 9, 0, 1, 0, 11...
1
128
9
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #inclu...
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #inclu...
[["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["-", 49, 50, 51, 16, 12, 23, 0, 16, 31, 13], ["+", 51, 16, 31, 16, 12, 23, 0, 16, 31, 13], ["-", 51, 16, 12, 23, 0, 16, 12, 16, 17, 85], ["-", 51, 16, 12, 23, 0, 16, 12, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 85], ["+", 8, ...
1
321
8
#include <iostream> #include <vector> using namespace std; int main() { int n, m, p; while (cin >> n >> m >> p, n && m && p) { vector<int> vec(n, 0); for (int i = 0; i < n; i++) { cin >> vec[i]; } int sum = 0; for (int i = 0; i < n; i++) { sum += vec[i]; } sum = sum * (100 - ...
#include <iostream> #include <vector> using namespace std; int main() { int n, m, p; while (cin >> n >> m >> p, n | m | p) { vector<int> vec(n, 0); for (int i = 0; i < n; i++) { cin >> vec[i]; } int sum = 0; for (int i = 0; i < n; i++) { sum += vec[i]; } sum = sum * (100 - p...
[["-", 15, 339, 51, 34, 12, 16, 31, 16, 17, 98], ["+", 15, 339, 51, 34, 12, 16, 31, 16, 17, 139], ["-", 0, 52, 15, 339, 51, 34, 12, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 139]]
1
151
4
#include <iostream> #include <vector> int main(int argc, char const *argv[]) { while (true) { int N, M, P; std::cin >> N >> M >> P; if (N == 0 && M == 0 && P == 0) break; std::vector<int> X(N); double pool = 0.0; for (int i = 0; i < N; ++i) { std::cin >> X[i]; pool += X[i] *...
#include <iostream> #include <vector> int main(int argc, char const *argv[]) { while (true) { int N, M, P; std::cin >> N >> M >> P; if (N == 0 && M == 0 && P == 0) break; std::vector<int> X(N); double pool = 0.0; for (int i = 0; i < N; ++i) { std::cin >> X[i]; pool += X[i] *...
[["-", 0, 43, 49, 50, 51, 16, 31, 23, 0, 24], ["-", 49, 50, 51, 16, 31, 23, 0, 16, 31, 13], ["+", 0, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 49, 50, 51, 16, 12, 16, 31, 23, 0, 24]]
1
175
4
while True: N, M, P = map(int, input().split()) if N == 0 and M == 0 and P == 0: break X = [int(input()) for _ in range(N)] win = X[M - 1] if win == 0: print(0) else: print(int(sum(X) * 100 * (1 - P / 100) // win))
while True: N, M, P = map(int, input().split()) if N == 0 and M == 0 and P == 0: break X = [int(input()) for _ in range(N)] win = X[M - 1] if win == 0: print(0) else: print(int(round(sum(X) * 100 * (1 - P / 100) / win, 10)))
[["+", 3, 4, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 17, 676], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 85], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
93
7
#!/usr/bin/env python # -*- coding: utf-8 -*- while True: N,M,P = map(int,input().split(" ")) if N == 0 and M == 0 and P == 0: break count = 0 for i in range(N): x = int(input()) count += x if i + 1 == M: hitman = x if hitman == 0: print(0) el...
#!/usr/bin/env python # -*- coding: utf-8 -*- while True: N,M,P = map(int,input().split(" ")) if N == 0 and M == 0 and P == 0: break count = 0 for i in range(N): x = int(input()) count += x if i + 1 == M: hitman = x if hitman == 0: print(0) el...
[["-", 0, 657, 31, 657, 31, 23, 0, 657, 17, 48], ["-", 0, 657, 31, 657, 31, 23, 0, 657, 12, 612], ["-", 0, 657, 31, 657, 12, 23, 0, 657, 17, 85], ["-", 0, 657, 31, 657, 12, 23, 0, 657, 12, 612]]
5
106
4
#!/usr/bin/python # -*- coding: utf-8 -*- import math while True: amount, number, per = map(int, input().split()) if amount == 0 and number == 0 and per == 0: break vote = [int(input()) for i in range(amount)] # for _ in range(amount): # vote.append(int(input())) if vote[number-1]...
#!/usr/bin/python # -*- coding: utf-8 -*- import math while True: amount, number, per = map(int, input().split()) if amount == 0 and number == 0 and per == 0: break vote = [int(input()) for _ in range(amount)] if vote[number-1] == 0: print("0") else: print(math.floor(100 *...
[["-", 0, 1, 0, 662, 12, 658, 0, 659, 31, 22], ["+", 0, 1, 0, 662, 12, 658, 0, 659, 31, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 0, 657, 31, 23, 0, 657, 12, 23, 0, 24], ["-", 0, 657, 31, 23, 0, 657, 12, 23, 0, 25], ["-", 0, 652, 3, 4, 0, 657, 31, 23, 0, 25]]
5
109
6
def solve(n, m, p): tot = 0 a = 0 for i in range(n): x = int(input()) tot += 100 * x if i == m-1: a = x if a == 0: print(0) return tot *= (100-p) / 100.0 ans = int(tot / a) print(ans) while 1: n, m, p = map(int, input().split()) if n == 0: ...
def solve(n, m, p): tot = 0 a = 0 for i in range(n): x = int(input()) tot += 100 * x if i == m-1: a = x if a == 0: print(0) return tot = tot * (100-p) / 100.0 ans = int(tot / a) print(ans) while 1: n, m, p = map(int, input().split()) if n =...
[["-", 0, 14, 8, 196, 0, 1, 0, 677, 17, 108], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 1, 0, 662, 12, 657, 31, 657, 31, 22], ["+", 0, 1, 0, 662, 12, 657, 31, 657, 17, 48]]
5
113
4