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
/* AOJ 0281 Title:Formation @kankichi573 */ #include <stdio.h> #define min(x, y) ((x) > (y) ? (y) : (x)) int Q; int solve(int c, int a, int n) { int ret, w; // printf("CAN=%d %d %d\n",c,a,n); if (c + a + n < 3 || c == 0) ret = 0; else if (a == 0 && n == 0) ret = c / 3; else if (n == 0) { if (2 * a <= c) ret = a + solve(c - 2 * a, 0, 0); else ret = c / 2; } else { w = min(c, min(a, n)); ret = w + solve(c - w, a - w, n - w); } return (ret); } main() { int c, a, n, ret; int i; scanf("%d", &Q); for (i = 0; i < Q; i++) { scanf("%d %d %d", &c, &a, &n); ret = solve(c, a, n); printf("%d\n", ret); } return (0); }
/* AOJ 0281 Title:Formation @kankichi573 */ #include <stdio.h> #define min(x, y) ((x) > (y) ? (y) : (x)) int Q; int solve(int c, int a, int n) { int ret, w; // printf("CAN=%d %d %d\n",c,a,n); if (c + a + n < 3 || c == 0) ret = 0; else if (a == 0) ret = c / 3; else if (n == 0) { if (2 * a <= c) ret = a + solve(c - 2 * a, 0, 0); else ret = c / 2; } else { w = min(c, min(a, n)); ret = w + solve(c - w, a - w, n - w); } return (ret); } main() { int c, a, n, ret; int i; scanf("%d", &Q); for (i = 0; i < Q; i++) { scanf("%d %d %d", &c, &a, &n); ret = solve(c, a, n); printf("%d\n", ret); } return (0); }
[["-", 75, 76, 0, 57, 15, 23, 0, 16, 17, 98], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 17, 60], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 12, 13]]
0
236
4
#include <stdio.h> int main(void) { int q, c, a, n, i, j, count; scanf("%d", &q); for (i = 0; i < q; i++) { count = 0; scanf("%d%d%d", &c, &a, &n); if (c <= a && c <= n) { count += c; a -= c, n -= c, c = 0; } else if (a <= c && a <= n) { count += a; c -= a, n -= a, a = 0; } else { count += n; c -= n, a -= n, n = 0; } if (2 * a <= c) { count += a; c -= 2 * a, a = 0; } else { count += c / 2; a -= c / 2, c -= 0; } count += c / 3; printf("%d\n", count); } return 0; }
#include <stdio.h> int main(void) { int q, c, a, n, i, j, count; scanf("%d", &q); for (i = 0; i < q; i++) { count = 0; scanf("%d%d%d", &c, &a, &n); if (c <= a && c <= n) { count += c; a -= c, n -= c, c = 0; } else if (a <= c && a <= n) { count += a; c -= a, n -= a, a = 0; } else { count += n; c -= n, a -= n, n = 0; } if (2 * a <= c) { count += a; c -= 2 * a, a = 0; } else { count += c / 2; a -= c / 2, c = 0; } count += c / 3; printf("%d\n", count); } return 0; }
[["-", 0, 9, 0, 1, 0, 34, 12, 11, 17, 110], ["+", 0, 9, 0, 1, 0, 34, 12, 11, 17, 32]]
0
207
2
#include <stdio.h> int main() { int nen = 0, c = 0, a = 0, n = 0, ans = 0; scanf("%d", &nen); for (int i = 0; i < nen; i++) { scanf("%d%d%d", &c, &a, &n); while (1) { if (a == 0 || c == 0 || n == 0) { break; } c--; a--; n--; ans++; } while (1) { if (a == 0 || c > 1) { break; } c -= 2; a--; ans++; } while (2 < c) { c -= 3; ans++; } printf("%d", ans); ans = 0; } return 0; }
#include <stdio.h> int main() { int nen = 0, c = 0, a = 0, n = 0, ans = 0; scanf("%d", &nen); for (int i = 0; i < nen; i++) { scanf("%d%d%d", &c, &a, &n); while (1) { if (a == 0 || c == 0 || n == 0) { break; } c--; a--; n--; ans++; } while (1) { if (a == 0 || 2 > c) { break; } c -= 2; a--; ans++; } while (2 < c) { c -= 3; ans++; } printf("%d\n", ans); ans = 0; } return 0; }
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 13], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
168
5
#include <iostream> using namespace std; int main() { int Q = 0; int C[101]; int A[101]; int N[101]; int cun[101]; cin >> Q; for (int i = 0; i < Q; i++) { cin >> C[i] >> A[i] >> N[i]; cun[i] = 0; } for (int i = 0; i < Q; i++) { while ((A[i] >= 1) && (C[i] >= 1) && (N[i] >= 1)) { N[i]--; C[i]--; A[i]--; cun[i]++; } while ((A[i] >= 1) && (C[i] >= 3)) { C[i]--; C[i]--; A[i]--; cun[i]++; } while (C[i] >= 3) { C[i]--; C[i]--; C[i]--; cun[i]++; } } for (int i = 0; i < Q; i++) { cout << cun[i] << endl; } return 0; }
#include <iostream> using namespace std; int main() { int Q = 0; int C[101]; int A[101]; int N[101]; int cun[101]; cin >> Q; for (int i = 0; i < Q; i++) { cin >> C[i] >> A[i] >> N[i]; cun[i] = 0; } for (int i = 0; i < Q; i++) { while ((A[i] >= 1) && (C[i] >= 1) && (N[i] >= 1)) { N[i]--; C[i]--; A[i]--; cun[i]++; } while ((A[i] >= 1) && (C[i] >= 2)) { C[i]--; C[i]--; A[i]--; cun[i]++; } while (C[i] >= 3) { C[i]--; C[i]--; C[i]--; cun[i]++; } } for (int i = 0; i < Q; i++) { cout << cun[i] << endl; } return 0; }
[["-", 15, 339, 51, 16, 12, 23, 0, 16, 12, 13], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 12, 13]]
1
265
2
#include <bits/stdc++.h> using namespace std; int main() { int q; scanf("%d", &q); while (q--) { int c, a, n; scanf("%d %d %d", &c, &a, &n); int res = 0; while (c & a & n) { c--; a--; n--; res++; } while (c >= 2 && a) { c -= 2; a--; res++; } while (c >= 3) { c -= 3; res++; } printf("%d\n", res); } }
#include <bits/stdc++.h> using namespace std; int main() { int q; scanf("%d", &q); while (q--) { int c, a, n; scanf("%d %d %d", &c, &a, &n); int res = 0; while (c && a && n) { c--; a--; n--; res++; } while (c >= 2 && a) { c -= 2; a--; res++; } while (c >= 3) { c -= 3; res++; } printf("%d\n", res); } }
[["-", 0, 52, 15, 339, 51, 16, 31, 16, 17, 67], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 17, 98], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 67], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98]]
1
127
4
#define _CRT_SECUREj_NO_WARNINGS 1 #define _USE_MATH_DEFINES #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <forward_list> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define INF ((int)(1 << 25)) #define REP(i, n) for (int i = 0; i < (int)n; i++) #define FOR(i, n) REP(i, n) #define TORAD 2.0 * M_PI / 360.0 #define INT(x) \ int x; \ cin >> x; #define ALL(x) (x).begin(), (x).end() #define RALL(x) (x).rbegin(), (x).rend() #define DEBUG(x) cout << #x << " :" << x << endl; #define EPS 1e-12 template <class T> void debug(T a) { for (auto iiiiiiiiii : a) cout << iiiiiiiiii << endl; } typedef vector<int> vi; typedef vector<string> vs; typedef pair<int, int> pii; typedef pair<int, pii> piii; int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; signed main() { INT(Q); while (Q--) { int c, a, n; cin >> c >> a >> n; int ans[3] = {}; ans[0] = min({c, a, n}); c -= 1 * ans[0]; a -= 1 * ans[0]; n -= 1 * ans[0]; ans[1] = min({c * 2, a}); c -= 2 * ans[1]; a -= 1 * ans[1]; n -= 0 * ans[1]; ans[2] = c / 3; cout << accumulate(begin(ans), end(ans), 0) << endl; } }
#define _CRT_SECUREj_NO_WARNINGS 1 #define _USE_MATH_DEFINES #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <forward_list> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define INF ((int)(1 << 25)) #define REP(i, n) for (int i = 0; i < (int)n; i++) #define FOR(i, n) REP(i, n) #define TORAD 2.0 * M_PI / 360.0 #define INT(x) \ int x; \ cin >> x; #define ALL(x) (x).begin(), (x).end() #define RALL(x) (x).rbegin(), (x).rend() #define DEBUG(x) cout << #x << " :" << x << endl; #define EPS 1e-12 template <class T> void debug(T a) { for (auto iiiiiiiiii : a) cout << iiiiiiiiii << endl; } typedef vector<int> vi; typedef vector<string> vs; typedef pair<int, int> pii; typedef pair<int, pii> piii; int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; signed main() { INT(Q); while (Q--) { int c, a, n; cin >> c >> a >> n; int ans[3] = {}; ans[0] = min({c, a, n}); c -= 1 * ans[0]; a -= 1 * ans[0]; n -= 1 * ans[0]; ans[1] = min({c / 2, a}); c -= 2 * ans[1]; a -= 1 * ans[1]; n -= 0 * ans[1]; ans[2] = c / 3; cout << accumulate(begin(ans), end(ans), 0) << endl; } }
[["-", 12, 2, 3, 4, 0, 83, 0, 16, 17, 48], ["+", 12, 2, 3, 4, 0, 83, 0, 16, 17, 85]]
1
346
2
#include <algorithm> #include <queue> #include <stdio.h> #include <stdlib.h> #include <string.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define rrep(i, n) for (int i = 1; i <= n; ++i) using namespace std; typedef pair<int, int> P; const int INF = 1000000000; int c, a, n; int main() { int q; scanf("%d", &q); rep(i, q) { scanf("%d%d%d", &c, &a, &n); int ans = 0, temp; temp = min(c, min(a, n)); ans += temp; a -= temp; c -= temp; temp = min(c / 2, a); ans += temp; c -= temp; ans += c / 3; printf("%d\n", ans); } return 0; }
#include <algorithm> #include <queue> #include <stdio.h> #include <stdlib.h> #include <string.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define rrep(i, n) for (int i = 1; i <= n; ++i) using namespace std; typedef pair<int, int> P; const int INF = 1000000000; int c, a, n; int main() { int q; scanf("%d", &q); rep(i, q) { scanf("%d%d%d", &c, &a, &n); int ans = 0, temp; temp = min(c, min(a, n)); ans += temp; a -= temp; c -= temp; temp = min(c / 2, a); ans += temp; c -= temp * 2; ans += c / 3; printf("%d\n", ans); } return 0; }
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
166
2
#include <iostream> using namespace std; int n, a, b, c, sum; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b >> c; while (c > 0 && a > 0 && b > 0) { a--; b--; c--; sum++; } while (a > 1 && b > 0) { a -= 2; b--; sum++; } while (a > 2) { a -= 3; sum++; } cout << sum << endl; } }
#include <iostream> using namespace std; int n, a, b, c, sum; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b >> c; sum = 0; while (c > 0 && a > 0 && b > 0) { a--; b--; c--; sum++; } while (a > 1 && b > 0) { a -= 2; b--; sum++; } while (a > 2) { a -= 3; sum++; } cout << sum << endl; } }
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
122
4
#include <stdio.h> #define MAX 100 int main() { int Q, tc, ta, tn; int c[MAX], a[MAX], n[MAX], team; scanf("%d", &Q); for (int i = 0; i < Q; i++) { scanf("%d %d %d", &c[i], &a[i], &n[i]); } for (int i = 0; i < Q; i++) { tc = c[i]; ta = a[i]; tn = n[i]; team = 0; while (tc > 0 && ta > 0 && tn > 0) { tc--; ta--; tn--; team++; } while (tc > 1 && ta > 1) { tc -= 2; ta--; team++; } while (tc > 2) { tc -= 3; team++; }; printf("%d\n", team); } return 0; }
#include <stdio.h> #define MAX 100 int main() { int Q, tc, ta, tn; int c[MAX], a[MAX], n[MAX], team; scanf("%d", &Q); for (int i = 0; i < Q; i++) { scanf("%d %d %d", &c[i], &a[i], &n[i]); } for (int i = 0; i < Q; i++) { tc = c[i]; ta = a[i]; tn = n[i]; team = 0; while (tc > 0 && ta > 0 && tn > 0) { tc--; ta--; tn--; team++; } while (tc > 1 && ta > 0) { tc -= 2; ta--; team++; } while (tc > 2) { tc -= 3; team++; }; printf("%d\n", team); } return 0; }
[["-", 0, 52, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 12, 13]]
1
209
2
#include <cstdio> #include <iostream> using namespace std; int main() { int a, b, c, n, m, j; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b >> c; m = 0; while (1) { if (c > 0 && b > 0 && a > 0) { c--; b--; a--; m++; } else j++; if (j > 0 && a > 1 && b > 0) { b--; a--; a--; m++; } else if (j > 0 && a < 2 || j > 0 && b < 1) break; } cout << m + a / 3 << endl; } return 0; }
#include <cstdio> #include <iostream> using namespace std; int main() { int a, b, c, n, m, j; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b >> c; j = 0; m = 0; while (1) { if (c > 0 && b > 0 && a > 0) { c--; b--; a--; m++; } else j++; if (j > 0 && a > 1 && b > 0) { b--; a--; a--; m++; } else if (j > 0 && a < 2 || j > 0 && b < 1) break; } cout << m + a / 3 << endl; } return 0; }
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
159
4
#include <iostream> using namespace std; #include <algorithm> int main() { int q; cin >> q; for (int i = 0; i < q; ++i) { int c, a, n; cin >> c >> a >> n; int cnt = min(c, min(a, n)); c -= cnt; a -= cnt; n -= cnt; if (a > 0) { if (c > 2) { if (c >= a * 2) { cnt += a; c -= a * 2; a = 0; } else { cnt += c / 2; c = 0; a -= c / 2; } } } if (c >= 3) { cnt += c / 3; } cout << cnt << endl; } return 0; }
#include <iostream> using namespace std; #include <algorithm> int main() { int q; cin >> q; for (int i = 0; i < q; ++i) { int c, a, n; cin >> c >> a >> n; int cnt = min(c, min(a, n)); c -= cnt; a -= cnt; n -= cnt; if (a >= 1) { if (c >= 2) { if (c >= a * 2) { cnt += a; c -= a * 2; a = 0; } else { cnt += c / 2; c = 0; a -= c / 2; } } } if (c >= 3) { cnt += c / 3; } cout << cnt << 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], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
161
6
#include <iostream> using namespace std; int main() { int n, c, a, m; int i; int cnt; cin >> n; for (i = 0; i < n; i++) { cnt = 0; cin >> c >> a >> m; if (c == 0) ; else if (a > 0) { while (c > 0 && a > 0 && m > 0) { c--; a--; m--; cnt++; } while (c > 1 && a > 0) { c -= 2; a--; cnt++; } cnt += c / 3; } cout << cnt << endl; } return 0; }
#include <iostream> using namespace std; int main() { int n, c, a, m; int i; int cnt; cin >> n; for (i = 0; i < n; i++) { cnt = 0; cin >> c >> a >> m; if (c == 0) ; else if (a > 0) { while (c > 0 && a > 0 && m > 0) { c--; a--; m--; cnt++; } while (c > 1 && a > 0) { c -= 2; a--; cnt++; } } cnt += c / 3; cout << cnt << endl; } return 0; }
[["+", 0, 57, 75, 76, 0, 57, 64, 9, 0, 46], ["-", 0, 57, 75, 76, 0, 57, 64, 9, 0, 46]]
1
139
2
#include <iostream> using namespace std; void solve() { int Q; cin >> Q; for (int i = 0; i < Q; ++i) { int c, a, n; cin >> c >> a >> n; int team = min(c, min(a, n)); c -= team; a -= team; n -= team; if (c * 2 >= a) { team += a; c -= a * 2; a = 0; } else { team += c / 2; a -= c / 2; c = 0; } team += c / 3; cout << team << endl; } } int main() { solve(); return (0); }
#include <iostream> using namespace std; void solve() { int Q; cin >> Q; for (int i = 0; i < Q; ++i) { int c, a, n; cin >> c >> a >> n; int team = min(c, min(a, n)); c -= team; a -= team; n -= team; if (c >= 2 * a) { team += a; c -= a * 2; a = 0; } else { team += c / 2; a -= c / 2; c = 0; } team += c / 3; cout << team << endl; } } int main() { solve(); return (0); }
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48]]
1
147
4
#include <iostream> using namespace std; int main(void) { for (;;) { int a; cin >> a; if (a == 0) break; int b[a], goukei = 0, m = 0; for (int A = 0; A < a; A++) cin >> b[A]; for (int B = 0; B < a; B++) { if (b[B] >= 1) { goukei += 1; b[B] -= 1; } } for (int A = 0; A < a; A++) { if (b[A] >= 1) { m = 3; goukei += 1; cout << goukei << endl; } } if (m == 0) cout << "NA" << endl; goukei = 0; } return 0; }
#include <iostream> using namespace std; int main(void) { for (;;) { int a; cin >> a; if (a == 0) break; int b[a], goukei = 0, m = 0; for (int A = 0; A < a; A++) cin >> b[A]; for (int B = 0; B < a; B++) { if (b[B] >= 1) { goukei += 1; b[B] -= 1; } } for (int A = 0; A < a; A++) { if (b[A] >= 1) { m = 3; goukei += 1; cout << goukei << endl; break; } } if (m == 0) cout << "NA" << endl; goukei = 0; } return 0; }
[["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
170
2
#include <bits/stdc++.h> using namespace std; int main() { int a, n, i, m, k; cin >> n; m = n; while (n != 0) { k = 0; for (i = 1; i <= n; i++) { cin >> a; if (a <= 0) { m--; } if (a >= 1) { k++; } } if (m <= 0) { cout << "NA" << endl; } else { cout << k + 1 << endl; } cin >> n; m = n; } }
#include <bits/stdc++.h> using namespace std; int main() { int a, n, i, m, k; cin >> n; m = n; while (n != 0) { k = 0; for (i = 1; i <= n; i++) { cin >> a; if (a <= 1) { m--; } if (a >= 1) { k++; } } if (m <= 0) { cout << "NA" << endl; } else { cout << k + 1 << endl; } cin >> n; m = n; } }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
119
2
#include <iostream> using namespace std; int N, a, b, c; int main() { for (;;) { cin >> N; if (N == 0) { a = 1; b = 0; for (int i = 0; i < N; i++) { cin >> c; if (c != 0) { a++; } if (c > 1) { b++; } } if (b == 0) { cout << "NA" << endl; } else { cout << a << endl; } } else { break; } } }
#include <iostream> using namespace std; int N, a, b, c; int main() { for (;;) { cin >> N; if (N != 0) { a = 1; b = 0; for (int i = 0; i < N; i++) { cin >> c; if (c != 0) { a++; } if (c > 1) { b++; } } if (b == 0) { cout << "NA" << endl; } else { cout << a << endl; } } else { break; } } }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79]]
1
120
2
#include <iostream> using namespace std; int f(int x, int y, int a, int b) { if (x >= 5 && y >= 2) return (a * x + b * y) * 8 / 10; return (a * x + b * y); } int main() { int N; while (cin >> N) { int sum = 0, mx = 0; for (int i = 0; i < N; i++) { int x; cin >> x; if (x) { sum++; mx = max(x, mx); } } if (mx >= 2) { cout << sum + 1 << endl; } else { cout << "NA" << endl; } } }
#include <iostream> using namespace std; int f(int x, int y, int a, int b) { if (x >= 5 && y >= 2) return (a * x + b * y) * 8 / 10; return (a * x + b * y); } int main() { int N; while (cin >> N && N) { int sum = 0, mx = 0; for (int i = 0; i < N; i++) { int x; cin >> x; if (x) { sum++; mx = max(x, mx); } } if (mx >= 2) { cout << sum + 1 << endl; } else { cout << "NA" << endl; } } }
[["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
1
153
2
#include <stdio.h> int main(void) { int i, s, k, max, kai; while (0 == 0) { scanf("%d", &k); if (k == 0) break; kai = k; scanf("%d", &s); max = s; if (s == 0) kai--; for (i = 1; i < k; i++) { scanf(" %d", &s); if (max < s) max = s; if (s == 0) kai--; } if (max < 2) printf("NA\n"); else printf("%d\n", k + 1); } return 0; }
#include <stdio.h> int main(void) { int i, s, k, max, kai; while (0 == 0) { scanf("%d", &k); if (k == 0) break; kai = k; scanf("%d", &s); max = s; if (s == 0) kai--; for (i = 1; i < k; i++) { scanf(" %d", &s); if (max < s) max = s; if (s == 0) kai--; } if (max < 2) printf("NA\n"); else printf("%d\n", kai + 1); } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22]]
1
147
2
#include <algorithm> #include <iostream> using namespace std; #define MAX 11000 int main() { long long int n; long long int input[MAX]; while (cin >> n && n != 0) { long long int _min = 99999999; long long int all = 0; long long int _max = 0; long long int zero = 0; for (long long int i = 0; i < n; i++) { long long int c; cin >> c; all += c; _max = max(_max, c); _min = min(c, _min); if (c == 0) { zero++; } } if (_min <= 1) { cout << "NA" << endl; } else if (n == 1) { cout << "2" << endl; } else { cout << n + 1 - zero << endl; } } return 0; }
#include <algorithm> #include <iostream> using namespace std; #define MAX 11000 int main() { long long int n; long long int input[MAX]; while (cin >> n && n != 0) { long long int _min = 99999999; long long int all = 0; long long int _max = 0; long long int zero = 0; for (long long int i = 0; i < n; i++) { long long int c; cin >> c; all += c; _max = max(_max, c); _min = min(c, _min); if (c == 0) { zero++; } } if (_max <= 1) { cout << "NA" << endl; } else if (n == 1) { cout << "2" << endl; } else { cout << n + 1 - zero << endl; } } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
179
2
#include <iostream> using namespace std; int main() { // your code goes here int n, k[10000]; while (cin >> n) { if (n == 0) break; int maxim = 0, sum = 0; for (int i = 0; i < n; i++) { cin >> k[i]; sum += (1 & k[i]); maxim = max(maxim, k[i]); } if (maxim <= 1) cout << "NA" << endl; else cout << sum + 1 << endl; } return 0; }
#include <iostream> using namespace std; int main() { // your code goes here int n, k[10000]; while (cin >> n) { if (n == 0) break; int maxim = 0, sum = 0; for (int i = 0; i < n; i++) { cin >> k[i]; sum += (int)(bool)(k[i]); maxim = max(maxim, k[i]); } if (maxim <= 1) cout << "NA" << endl; else cout << sum + 1 << endl; } return 0; }
[["-", 0, 1, 0, 11, 12, 23, 0, 16, 31, 13], ["-", 0, 1, 0, 11, 12, 23, 0, 16, 17, 67], ["+", 0, 1, 0, 11, 12, 74, 39, 77, 39, 40], ["+", 8, 9, 0, 1, 0, 11, 12, 74, 0, 25], ["+", 0, 1, 0, 11, 12, 74, 51, 74, 0, 24], ["+", 0, 11, 12, 74, 51, 74, 39, 77, 39, 40], ["+", 0, 1, 0, 11, 12, 74, 51, 74, 0, 25], ["+", 0, 11, 12, 74, 51, 74, 51, 23, 0, 24]]
1
118
8
import java.io.*; import java.math.*; import java.util.*; class Main { public static void main(String[] args) throws IOException { // BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); Scanner r = new Scanner(System.in); char[] c; String s; int[] huda = new int[10]; int n; int turn; int field; int i, j; while (r.hasNext()) { turn = 0; field = 0; s = r.next(); n = Integer.parseInt(s); if (n == 0) break; for (i = 0; i < n; i++) huda[i] = 0; s = r.next(); c = s.toCharArray(); for (i = 0; i < 100; i++) { switch (c[i]) { case 'M': huda[turn]++; break; case 'S': field += huda[turn] + 1; huda[turn] = 0; break; case 'L': huda[turn] += field + 1; field = 0; break; } if (turn + 1 == n) turn = 0; else turn++; } Arrays.sort(huda, 0, n - 1); for (i = 0; i < n; i++) System.out.print(huda[i] + " "); System.out.println(field); } } }
import java.io.*; import java.math.*; import java.util.*; class Main { public static void main(String[] args) throws IOException { // BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); Scanner r = new Scanner(System.in); char[] c; String s; int[] huda = new int[10]; int n; int turn; int field; int i, j; while (r.hasNext()) { turn = 0; field = 0; s = r.next(); n = Integer.parseInt(s); if (n == 0) break; for (i = 0; i < n; i++) huda[i] = 0; s = r.next(); c = s.toCharArray(); for (i = 0; i < 100; i++) { switch (c[i]) { case 'M': huda[turn]++; break; case 'S': field += huda[turn] + 1; huda[turn] = 0; break; case 'L': huda[turn] += field + 1; field = 0; break; } if (turn + 1 == n) turn = 0; else turn++; } Arrays.sort(huda, 0, n); for (i = 0; i < n; i++) System.out.print(huda[i] + " "); System.out.println(field); } } }
[["-", 0, 1, 0, 492, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 492, 3, 4, 0, 16, 12, 499]]
3
304
2
import java.util.*; class Main { Scanner sc = new Scanner(System.in); void main() { while (true) { int n = sc.nextInt(); if (n == 0) break; int[] pr = new int[n]; int fld = 0; String cd = sc.next(); for (int i = 0; i < 100; i++) { char ch = cd.charAt(i); if (cd.charAt(i) == 'M') pr[i % n]++; if (cd.charAt(i) == 'S') { fld += pr[i % n] + 1; pr[i % n] = 0; } if (cd.charAt(i) == 'L') { pr[i % n] += fld + 1; fld = 0; } } for (int i = 0; i < n - 1; i++) { int min = i; for (int j = i + 1; j < n; j++) { if (pr[min] > pr[j]) { int cj = pr[min]; pr[min] = pr[j]; pr[j] = cj; } } } for (int i = 0; i < n; i++) System.out.println(pr[i] + " "); System.out.println(fld); } } public static void main(String[] ag) { new Main().main(); } }
import java.util.*; class Main { Scanner sc = new Scanner(System.in); void main() { while (true) { int n = sc.nextInt(); if (n == 0) break; int[] pr = new int[n]; int fld = 0; String cd = sc.next(); for (int i = 0; i < 100; i++) { char ch = cd.charAt(i); if (cd.charAt(i) == 'M') pr[i % n]++; if (cd.charAt(i) == 'S') { fld += pr[i % n] + 1; pr[i % n] = 0; } if (cd.charAt(i) == 'L') { pr[i % n] += fld + 1; fld = 0; } } for (int i = 0; i < n - 1; i++) { int min = i; for (int j = i + 1; j < n; j++) { if (pr[min] > pr[j]) { int cj = pr[min]; pr[min] = pr[j]; pr[j] = cj; } } } for (int i = 0; i < n; i++) System.out.print(pr[i] + " "); System.out.println(fld); } } public static void main(String[] ag) { new Main().main(); } }
[["-", 8, 196, 0, 7, 8, 1, 0, 492, 141, 22], ["+", 8, 196, 0, 7, 8, 1, 0, 492, 141, 22]]
3
322
2
#include <stdio.h> int main(void) { int n; char card[101], field; int i, j, par[10]; int tmp; while (scanf("%d", &n) * n != 0) { field = 0; for (i = 0; i < 10; i++) { par[i] = 0; } scanf("%s", card); for (i = 0; card[i] != 0; i++) { switch (card[i]) { case 'M': par[i % n]++; break; case 'S': field += par[i % n] + 1; par[i % n] = 0; break; case 'L': par[i % n] += field; field = 0; break; } } for (i = 0; i < n - 1; i++) { for (j = 0; j < n - 1; j++) { if (par[j] > par[j + 1]) { tmp = par[j]; par[j] = par[j + 1]; par[j + 1] = tmp; } } } for (i = 0; i < n; i++) { printf("%d ", par[i]); } printf("%d\n", field); } return (0); }
#include <stdio.h> int main(void) { int n; char card[101], field; int i, j, par[10]; int tmp; while (scanf("%d", &n) * n != 0) { field = 0; for (i = 0; i < 10; i++) { par[i] = 0; } scanf("%s", card); for (i = 0; card[i] != 0; i++) { switch (card[i]) { case 'M': par[i % n]++; break; case 'S': field += par[i % n] + 1; par[i % n] = 0; break; case 'L': par[i % n] += field + 1; field = 0; break; } } for (i = 0; i < n - 1; i++) { for (j = 0; j < n - 1; j++) { if (par[j] > par[j + 1]) { tmp = par[j]; par[j] = par[j + 1]; par[j + 1] = tmp; } } } for (i = 0; i < n; i++) { printf("%d ", par[i]); } printf("%d\n", field); } return (0); }
[["+", 0, 100, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 100, 0, 1, 0, 11, 12, 16, 12, 13]]
0
295
2
#include <stdio.h> int main() { int N; int p[20] = {0}; int i, j, temp, s; int ba = 0; char c[200]; while (1) { scanf("%d", &N); if (N == 0) { break; } ba = 0; for (i = 0; i < 10; i++) { p[i] = 0; } scanf("%s", c); for (j = 0; j < 100; j++) { s = j % N; if (c[j] == 'M') { p[s]++; } else if (c[j] == 'S') { ba = ba + p[s]; p[s] = 0; ba++; } else if (c[j] == 'L') { p[s] = p[s] + ba; ba = 0; p[s]++; } } for (i = 0; i < N; i++) { for (j = N - 1; j > i; j--) { if (p[i] > p[j]) { temp = p[i]; p[i] = p[j]; p[j] = temp; } } } for (i = 0; i < N; i++) { printf(" %d", p[i]); } printf(" %d", ba); } return 0; }
#include <stdio.h> int main() { int N; int p[20] = {0}; int i, j, temp, s; int ba = 0; char c[200]; while (1) { scanf("%d", &N); if (N == 0) { break; } ba = 0; for (i = 0; i < 10; i++) { p[i] = 0; } scanf("%s", c); for (j = 0; j < 100; j++) { s = j % N; if (c[j] == 'M') { p[s]++; } else if (c[j] == 'S') { ba = ba + p[s]; p[s] = 0; ba++; } else if (c[j] == 'L') { p[s] = p[s] + ba; ba = 0; p[s]++; } } for (i = 0; i < N; i++) { for (j = N - 1; j > i; j--) { if (p[i] > p[j]) { temp = p[i]; p[i] = p[j]; p[j] = temp; } } } for (i = 0; i < N; i++) { printf("%d ", p[i]); } printf("%d\n", ba); } 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]]
0
320
5
a[11], j; main(N, i) { for (; scanf("%d", &N), j = N; memset(a, 0, sizeof(a))) { for (getchar(), i = 0; (j = getchar()) != '\n'; i++) if (j == 'M') a[i % N]++; else if (j - 'L') a[N] += a[i % N] + 1, a[i % N] = 0; else a[i % N] += a[N] + 1, a[N] = 0; for (i = 0; i < N - 1; i++) for (j = N - i - 1; j; j--) if (a[j] < a[j - 1]) a[j - 1] ^= a[j], a[j] ^= a[j - 1], a[j - 1] ^= a[j]; for (i = 0; i <= N; i++) printf(i < N ? "%d " : "%d\n", a[i]); } }
a[11], j; main(N, i) { for (; scanf("%d", &N), j = N; memset(a, 0, sizeof(a))) { for (getchar(), i = 0; (j = getchar()) != '\n'; i++) if (j == 'M') a[i % N]++; else if (j - 'L') a[N] += a[i % N] + 1, a[i % N] = 0; else a[i % N] += a[N] + 1, a[N] = 0; for (i = 0; i < N - 1; i++) for (j = N - 1; j > i; j--) if (a[j] < a[j - 1]) a[j - 1] ^= a[j], a[j] ^= a[j - 1], a[j - 1] ^= a[j]; for (i = 0; i <= N; i++) printf(i < N ? "%d " : "%d\n", a[i]); } }
[["-", 8, 7, 10, 11, 12, 16, 31, 16, 12, 22], ["-", 0, 7, 8, 7, 10, 11, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 8, 7, 15, 16, 17, 47], ["+", 8, 9, 0, 7, 8, 7, 15, 16, 12, 22]]
0
256
39
a[11], j; main(N, i) { for (; scanf("%d", &N), j = N; memset(a, 0, sizeof(a))) { for (getchar(), i = 0; (j = getchar()) != '\n'; i++) if (j == 'M') a[i % N]++; else if (j - 'L') a[N] += a[i % N] + 1, a[i % N] = 0; else a[i % N] += a[N] + 1, a[N] = 0; for (i = 0; i <= N; printf(i < N ? "%d " : "%d\n", a[i++])) for (j = N - 1; j > i; j--) if (a[j] < a[j - 1]) a[j - 1] ^= a[j], a[j] ^= a[j - 1], a[j - 1] ^= a[j]; } }
a[11], j; main(N, i) { for (; scanf("%d", &N), j = N; memset(a, 0, sizeof(a))) { for (getchar(), i = 0; (j = getchar()) != '\n'; i++) if (j == 'M') a[i % N]++; else if (j - 'L') a[N] += a[i % N] + 1, a[i % N] = 0; else a[i % N] += a[N] + 1, a[N] = 0; for (i = 0; i <= N; printf(i < N ? "%d " : "%d\n", a[i]), i++) for (j = N - 1; j > i; j--) if (a[j] < a[j - 1]) a[j - 1] ^= a[j], a[j] ^= a[j - 1], a[j - 1] ^= a[j]; } }
[["-", 26, 2, 3, 4, 0, 69, 71, 27, 17, 29], ["+", 0, 7, 8, 9, 0, 7, 26, 34, 0, 21], ["+", 8, 9, 0, 7, 26, 34, 12, 27, 28, 22], ["+", 8, 9, 0, 7, 26, 34, 12, 27, 17, 29]]
0
239
24
#include <algorithm> #include <iostream> using namespace std; string Card; int pk[10] = {0}; int N; int field; int main() { while (1) { int cnt = 0; cin >> N; if (N == 0) break; cin >> Card; while (cnt < 100) { for (int j = 0; j < N; j++, cnt++) { if (cnt > 100) break; if (Card[cnt] == 'M') { pk[j]++; } else if (Card[cnt] == 'S') { field += (1 + pk[j]); pk[j] = 0; } else { pk[j] += field + 1; field = 0; } } } sort(pk, pk + N); for (int i = 0; i < N; i++) { cout << pk[i] << " "; pk[i] = 0; } cout << field << endl; Card = '\0'; field = 0; } return 0; }
#include <algorithm> #include <iostream> using namespace std; string Card; int pk[10] = {0}; int N; int field; int main() { while (1) { int cnt = 0; cin >> N; if (N == 0) break; cin >> Card; while (cnt < 100) { for (int j = 0; j < N; j++, cnt++) { if (cnt >= 100) break; if (Card[cnt] == 'M') { pk[j]++; } else if (Card[cnt] == 'S') { field += (1 + pk[j]); pk[j] = 0; } else { pk[j] += field + 1; field = 0; } } } sort(pk, pk + N); for (int i = 0; i < N; i++) { cout << pk[i] << " "; pk[i] = 0; } cout << field << endl; Card = '\0'; field = 0; } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
224
2
#include <bits/stdc++.h> using namespace std; int n; string str; int p[10], f; int main() { while (cin >> n, n) { cin >> str; memset(p, 0, sizeof(p)); for (int i = 0; i < 100; i++) { int cur = i % n; if (str[i] == 'M') p[cur]++; else if (str[i] == 'S') { f += p[cur] + 1; p[cur] = 0; } else { p[cur] += f + 1; f = 0; } } sort(p, p + n); for (int i = 0; i < n; i++) printf("%d ", p[i]); printf("%d\n", f); } return 0; }
#include <bits/stdc++.h> using namespace std; int n; string str; int p[10], f; int main() { while (cin >> n, n) { cin >> str; memset(p, 0, sizeof(p)); f = 0; for (int i = 0; i < 100; i++) { int cur = i % n; if (str[i] == 'M') p[cur]++; else if (str[i] == 'S') { f += p[cur] + 1; p[cur] = 0; } else { p[cur] += f + 1; f = 0; } } sort(p, p + n); for (int i = 0; i < n; i++) printf("%d ", p[i]); printf("%d\n", f); } return 0; }
[["+", 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
186
4
#include <algorithm> #include <iostream> using namespace std; int main() { while (1) { char C[101]; int N = 0; int P[11]; int B = 0; int A = 0; cin >> N; if (N == 0) { break; } for (int i = 0; i < 10; i++) { P[i] = 0; } for (int i = 0; i < 100; i++) { cin >> C[i]; } for (int i = 0; i < 100; i++) { if (C[i] == 'M') { A = i % N; P[A]++; } if (C[i] == 'L') { A = i % N; P[A] = P[A] + B; P[A]++; B = 0; } if (C[i] == 'S') { A = i % N; B = B + P[A]; B++; P[A] = 0; } } sort(P, P + N - 1); for (int i = 0; i < N; i++) { cout << P[i] << " "; } cout << B << endl; } return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { while (1) { char C[101]; int N = 0; int P[11]; int B = 0; int A = 0; cin >> N; if (N == 0) { break; } for (int i = 0; i < 10; i++) { P[i] = 0; } for (int i = 0; i < 100; i++) { cin >> C[i]; } for (int i = 0; i < 100; i++) { if (C[i] == 'M') { A = i % N; P[A]++; } if (C[i] == 'L') { A = i % N; P[A] = P[A] + B; P[A]++; B = 0; } if (C[i] == 'S') { A = i % N; B = B + P[A]; B++; P[A] = 0; } } sort(P, P + N); for (int i = 0; i < N; i++) { cout << P[i] << " "; } cout << B << endl; } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
274
2
#include <algorithm> #include <iostream> using namespace std; int main() { int n, f = 0, i; char c; while (cin >> n, n != 0) { int a[n]; for (i = 0; i < n; i++) { a[i] = 0; } for (i = 0; i < 100; i++) { cin >> c; switch (c) { case 'M': a[i % n]++; break; case 'S': f += a[i % n] + 1; a[i % n] = 0; break; case 'L': a[i % n] += f + 1; f = 0; break; } } sort(a, a + n); for (i = 0; i < n; i++) { cout << a[i] << " "; } cout << f << endl; } return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { int n, f, i; char c; while (cin >> n, n != 0) { f = 0; int a[n]; for (i = 0; i < n; i++) { a[i] = 0; } for (i = 0; i < 100; i++) { cin >> c; switch (c) { case 'M': a[i % n]++; break; case 'S': f += a[i % n] + 1; a[i % n] = 0; break; case 'L': a[i % n] += f + 1; f = 0; break; } } sort(a, a + n); for (i = 0; i < n; i++) { cout << a[i] << " "; } cout << f << endl; } return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 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
199
6
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int main() { while (1) { int n; cin >> n; if (n == 0) break; string card; cin >> card; int p[10] = {0}, f = 0, t = 0; int c = 0; while (c < 100) { string s = card.substr(c, 1); if (s == "M") p[t]++; else if (s == "S") { f = p[t] + 1; p[t] = 0; } else if (s == "L") { p[t] += (f + 1); f = 0; } if (t == n - 1) t = 0; else t++; c++; } sort(p, p + n); for (int i = 0; i < n; i++) cout << p[i] << " "; cout << f << endl; } return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int main() { while (1) { int n; cin >> n; if (n == 0) break; string card; cin >> card; int p[10] = {0}, f = 0, t = 0; int c = 0; while (c < 100) { string s = card.substr(c, 1); if (s == "M") p[t]++; else if (s == "S") { f += p[t] + 1; p[t] = 0; } else if (s == "L") { p[t] += (f + 1); f = 0; } if (t == n - 1) t = 0; else t++; c++; } sort(p, p + n); for (int i = 0; i < n; i++) cout << p[i] << " "; cout << f << endl; } return 0; }
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]]
1
220
2
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { string S; int N; vector<int> P; int R; while (true) { cin >> N; if (N == 0) { break; } P = vector<int>(N, 0); R = 0; cin >> S; for (int i = 0; i < S.size(); i++) { int turn = i % N; if (S[i] == 'M') { P[turn] += 1; } else if (S[i] == 'S') { R = P[turn] + 1; P[turn] = 0; } else { P[turn] += R + 1; R = 0; } } sort(P.begin(), P.end()); for (int i = 0; i < N; i++) { cout << P[i] << ' '; } cout << R << endl; } return 0; }
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { string S; int N; vector<int> P; int R; while (true) { cin >> N; if (N == 0) { break; } P = vector<int>(N, 0); R = 0; cin >> S; for (int i = 0; i < S.size(); i++) { int turn = i % N; if (S[i] == 'M') { P[turn] += 1; } else if (S[i] == 'S') { R += P[turn] + 1; P[turn] = 0; } else { P[turn] += R + 1; R = 0; } } sort(P.begin(), P.end()); for (int i = 0; i < N; i++) { cout << P[i] << ' '; } cout << R << endl; } return 0; }
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]]
1
217
2
#include <iostream> using namespace std; #include <algorithm> #include <cstring> int main() { int n; int hand[100]; while (cin >> n && n != 0) { memset(hand, 0, sizeof(hand)); int field = 0; int num = 0; for (int i = 0; i < 100; i++) { char c; cin >> c; if (c == 'M') hand[num]++; else if (c == 'S') { field += hand[num] + 1; hand[num] = 0; } else { hand[num] += field + 1; field = 0; } if (num < n) num++; else num = 0; } sort(hand, hand + n); for (int i = 0; i < n; i++) cout << hand[i] << ' '; cout << field << endl; } }
#include <iostream> using namespace std; #include <algorithm> #include <cstring> int main() { int n; int hand[100]; while (cin >> n && n != 0) { memset(hand, 0, sizeof(hand)); int field = 0; int num = 0; for (int i = 0; i < 100; i++) { char c; cin >> c; if (c == 'M') hand[num]++; else if (c == 'S') { field += hand[num] + 1; hand[num] = 0; } else { hand[num] += field + 1; field = 0; } if (num + 1 < n) num++; else num = 0; } sort(hand, hand + n); for (int i = 0; i < n; i++) cout << hand[i] << ' '; cout << field << endl; } }
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]]
1
193
2
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { while (1) { int ba = 0; int a; string x; cin >> a; if (a == 0) break; cin >> x; vector<int> s(a); for (int b = 0; b < 100; b++) { s[b % a]++; switch (x[b]) { case 'S': ba += s[b % a]; s[b % a] = 0; break; default: s[b % a] += ba; ba = 0; break; } } sort(s.begin(), s.end()); for (int k : s) { cout << k << " "; } cout << ba << endl; } }
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { while (1) { int ba = 0; int a; string x; cin >> a; if (a == 0) break; cin >> x; vector<int> s(a); for (int b = 0; b < 100; b++) { s[b % a]++; switch (x[b]) { case 'S': ba += s[b % a]; s[b % a] = 0; break; case 'L': s[b % a] += ba; ba = 0; break; } } sort(s.begin(), s.end()); for (int k : s) { cout << k << " "; } cout << ba << endl; } }
[["-", 8, 9, 0, 99, 8, 9, 0, 100, 0, 162], ["+", 8, 9, 0, 99, 8, 9, 0, 100, 0, 173], ["+", 0, 99, 8, 9, 0, 100, 51, 103, 0, 104], ["+", 0, 99, 8, 9, 0, 100, 51, 103, 0, 125]]
1
173
5
#include <algorithm> #include <iostream> using namespace std; /*void sort(int* array, int index){ bool finish = true; while(finish){ finish = false; for(int i = 1; i < index; i++){ if(array[i - 1] > array[i]){ int temp = array[i - 1]; array[i - 1] = array[i]; array[i] = temp; finish = true; } } } }*/ int main(void) { while (true) { int n; cin >> n; if (n == 0) { break; } int players[5]; for (int i = 0; i < n; i++) { players[i] = 0; } char deck[100]; cin >> deck; int field = 0; for (int i = 0; i < 100; i++) { if (deck[i] == 'S') { field += players[i % n] + 1; players[i % n] = 0; } else if (deck[i] == 'M') { players[i % n]++; } else if (deck[i] == 'L') { players[i % n]++; players[i % n] += field; field = 0; } } sort(players, players + n); for (int i = 0; i < n; i++) { cout << players[i] << ' '; } cout << field << endl; } }
#include <algorithm> #include <iostream> using namespace std; /*void sort(int* array, int index){ bool finish = true; while(finish){ finish = false; for(int i = 1; i < index; i++){ if(array[i - 1] > array[i]){ int temp = array[i - 1]; array[i - 1] = array[i]; array[i] = temp; finish = true; } } } }*/ int main(void) { while (true) { int n; cin >> n; if (n == 0) { break; } int players[n]; for (int i = 0; i < n; i++) { players[i] = 0; } char deck[100]; cin >> deck; int field = 0; for (int i = 0; i < 100; i++) { if (deck[i] == 'S') { field += players[i % n] + 1; players[i % n] = 0; } else if (deck[i] == 'M') { players[i % n]++; } else if (deck[i] == 'L') { players[i % n]++; players[i % n] += field; field = 0; } } sort(players, players + n); for (int i = 0; i < n; i++) { cout << players[i] << ' '; } cout << field << endl; } }
[["-", 0, 52, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 80, 81, 22]]
1
231
2
#include <algorithm> #include <iostream> using namespace std; int main() { while (1) { int N; cin >> N; if (N == 0) break; int player[N + 1]; for (int i = 0; i < N + 1; i++) { player[i] = 0; } int all = 0; int num = 1; for (int i = 1; i < 101; i++) { char x; cin >> x; if (x == 'M') { player[num] += 1; num++; if (num >= N + 1) { num = 1; } } if (x == 'S') { all += player[num] + 1; player[num] = 0; num++; if (num >= N + 1) { num = 1; } } if (x == 'L') { player[num] += 1 + all; all = 0; num++; if (num >= N + 1) { num = 1; } } } sort(player + 1, player + N); for (int i = 1; i < N + 1; i++) { cout << player[i] << " "; } cout << all << endl; } return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { while (1) { int N; cin >> N; if (N == 0) break; int player[N + 1]; for (int i = 0; i < N + 1; i++) { player[i] = 0; } int all = 0; int num = 1; for (int i = 1; i < 101; i++) { char x; cin >> x; if (x == 'M') { player[num] += 1; num++; if (num >= N + 1) { num = 1; } } if (x == 'S') { all += player[num] + 1; player[num] = 0; num++; if (num >= N + 1) { num = 1; } } if (x == 'L') { player[num] += 1 + all; all = 0; num++; if (num >= N + 1) { num = 1; } } } sort(player + 1, player + N + 1); for (int i = 1; i < N + 1; i++) { cout << player[i] << " "; } cout << all << endl; } return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
267
2
#include <iostream> using namespace std; int main() { int n, m[15], st; int b; char f[150]; int i, j; int tmp; while (cin >> n, n) { for (i = 0; i < 15; i++) m[i] = 0; b = 0; st = 0; cin >> f; for (i = 0; i < 100; i++) { if (st == n) st = 0; if (f[i] == 'M') { m[st]++; } else if (f[i] == 'L') { m[st] += b + 1; b = 0; } else { b += m[st]; m[st] = 0; } st++; } for (i = 0; i < n - 1; i++) { for (j = i + 1; j < n; j++) { if (m[i] > m[j]) tmp = m[i]; m[i] = m[j]; m[j] = tmp; } } for (i = 0; i < n; i++) { cout << m[i] << " "; } cout << b << endl; } return 0; }
#include <iostream> using namespace std; int main() { int n, m[15], st; int b; char f[150]; int i, j; int tmp; while (cin >> n, n) { for (i = 0; i < 15; i++) m[i] = 0; b = 0; st = 0; cin >> f; // scanf("%s",f); for (i = 0; i < 100; i++) { if (st == n) st = 0; if (f[i] == 'M') { // cout << m[st] << endl ; m[st]++; } else if (f[i] == 'L') { // cout << m[st] << endl ; m[st] += b + 1; b = 0; } else { // cout << m[st] << endl ; b += m[st] + 1; m[st] = 0; } st++; } for (i = 0; i < n - 1; i++) { for (j = i + 1; j < n; j++) { if (m[i] > m[j]) { tmp = m[i]; m[i] = m[j]; m[j] = tmp; } } } for (i = 0; i < n; i++) { cout << m[i] << " "; } cout << b << endl; } return 0; }
[["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
277
4
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); int n = scanner.nextInt(); while (n-- > 0) { int num = Integer.MAX_VALUE / 2; int num2 = (1 << 8) - 1; long s = Long.parseLong(scanner.next(), 16); int x = (int)(s & num) >> 7; double y = (double)((s & num2) * 0.0078125); String a = String.valueOf(y).substring(2); if (s >> 31 > 0) System.out.print("-"); System.out.printf("%d.%s\n", x, a); } } }
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); int n = scanner.nextInt(); while (n-- > 0) { int num = Integer.MAX_VALUE; int num2 = (1 << 8) - 1; long s = Long.parseLong(scanner.next(), 16); int x = (int)(s & num) >> 7; double y = (double)((s & num2) * 0.0078125); String a = String.valueOf(y).substring(2); if (s >> 31 > 0) System.out.print("-"); System.out.printf("%d.%s\n", x, a); } } }
[["-", 8, 196, 0, 503, 49, 200, 51, 16, 17, 85], ["-", 8, 196, 0, 503, 49, 200, 51, 16, 12, 499]]
3
185
2
#include <math.h> #include <stdio.h> int main(void) { int n, i, j; scanf("%d", &n); for (i = 0; i < n; i++) { unsigned intp, decp; double dec; int hex, max; scanf("%x", &hex); intp = (hex >> 7) & 0xFFFFFF; decp = hex & 0x7F; dec = max = 0; for (j = 0; j < 7; j++) { if (decp & (1 << j)) { dec += pow(.5, j + 1); max = j; } } if (hex < 0) putchar('-'); printf("%.*lf\n", max + 1, intp + dec); } return (0); }
#include <math.h> #include <stdio.h> int main(void) { int n, i, j; scanf("%d", &n); for (i = 0; i < n; i++) { unsigned intp, decp; double dec; int hex, max; scanf("%x", &hex); intp = (hex >> 7) & 0xFFFFFF; decp = hex & 0x7F; dec = max = 0; for (j = 0; j < 7; j++) { if (decp & (1 << (6 - j))) { dec += pow(.5, j + 1); max = j; } } if (hex < 0) putchar('-'); printf("%.*lf\n", max + 1, intp + dec); } return (0); }
[["+", 0, 16, 12, 23, 0, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 16, 12, 23, 0, 16, 31, 13], ["+", 12, 23, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 23, 0, 16, 12, 23, 0, 25]]
0
164
4
/* AOJ 0268 Title: @kankichi573 */ #include <float.h> #include <stdio.h> #include <string.h> main() { float xx; int x, i, j, Q, sign; char buf[100]; scanf("%d", &Q); // printf("Q=%d\n",Q); for (i = 0; i < Q; i++) { scanf("%x", &x); if (x & 1 << 31) { sign = -1; x &= 0x7fffffff; } else sign = 1; xx = x / 128.0; if (x & 0x3f) { sprintf(buf, "%f", sign * xx); j = strlen(buf) - 1; while (buf[j] == '0') buf[j--] = '\0'; printf("%s\n", buf); } else printf("%.1f\n", sign * xx); } return (0); }
/* AOJ 0268 Title:Kongo Type @kankichi573 */ #include <float.h> #include <stdio.h> #include <string.h> main() { double xx; int x, i, j, Q, sign; char buf[100]; scanf("%d", &Q); // printf("Q=%d\n",Q); for (i = 0; i < Q; i++) { scanf("%x", &x); if (x & 1 << 31) { sign = -1; x &= 0x7fffffff; } else sign = 1; xx = x / 128.0; if (x & 0x3f) { sprintf(buf, "%0.7lf", sign * xx); j = strlen(buf) - 1; while (buf[j] == '0') buf[j--] = '\0'; printf("%s\n", buf); } else printf("%.1f\n", sign * xx); } return (0); }
[["-", 36, 36, 0, 30, 0, 9, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 9, 0, 43, 39, 40], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
177
4
#include <algorithm> #include <cstdio> #include <iostream> #include <string> using namespace std; #define rep(i, x) for (int i = 0; i < x; i++) #define rep1(i, x) for (int i = 1; i <= x; i++) int main() { double a[40]; int k[40]; int t = 1; for (int i = 24; i > 0; i--) { a[i] = t; k[i] = 1; t *= 2; } double tt = 1.0; for (int i = 25; i <= 31; i++) { tt /= 2; a[i] = tt; k[i] = i - 24; } /*a[25]=0.5; k[25]=1; a[26]=0.25; k[25]=1; a[27]=0.125; k[25]=1; a[28]=0.0625; k[25]=1; a[29]=0.03125; k[25]=1; a[30]=0.015625; k[25]=1; a[31]=0.0078125; k[25]=1;*/ int q; cin >> q; rep(ppp, q) { string s, t = ""; cin >> s; rep(i, 8) { int b = s[i]; if ('a' <= b && b <= 'f') b = 10 + b - 'a'; else b -= 48; int c[4] = {8, 4, 2, 1}; rep(j, 4) { if (b >= c[j]) t += '1'; else t += '0'; b %= c[j]; } } double ans = 0.0; int K = 1; rep1(i, 31) { if (t[i] == '1') { ans += a[i]; K = max(K, k[i]); } } if (t[0] == '1') printf("-"); if (K == 1) printf("%.1f\n", ans); if (K == 2) printf("%.2f\n", ans); if (K == 3) printf("%.3f\n", ans); if (K == 4) printf("%.4\n", ans); if (K == 5) printf("%.5f\n", ans); if (K == 6) printf("%.6f\n", ans); if (K == 7) printf("%.7f\n", ans); if (K == 8) printf("%.8f\n", ans); } }
#include <algorithm> #include <cstdio> #include <iostream> #include <string> using namespace std; #define rep(i, x) for (int i = 0; i < x; i++) #define rep1(i, x) for (int i = 1; i <= x; i++) int main() { double a[40]; int k[40]; int t = 1; for (int i = 24; i > 0; i--) { a[i] = t; k[i] = 1; t *= 2; } double tt = 1.0; for (int i = 25; i <= 31; i++) { tt /= 2; a[i] = tt; k[i] = i - 24; } /*a[25]=0.5; k[25]=1; a[26]=0.25; k[25]=1; a[27]=0.125; k[25]=1; a[28]=0.0625; k[25]=1; a[29]=0.03125; k[25]=1; a[30]=0.015625; k[25]=1; a[31]=0.0078125; k[25]=1;*/ int q; cin >> q; rep(ppp, q) { string s, t = ""; cin >> s; rep(i, 8) { int b = s[i]; if ('a' <= b && b <= 'f') b = 10 + b - 'a'; else b -= 48; int c[4] = {8, 4, 2, 1}; rep(j, 4) { if (b >= c[j]) t += '1'; else t += '0'; b %= c[j]; } } double ans = 0.0; int K = 1; rep1(i, 31) { if (t[i] == '1') { ans += a[i]; K = max(K, k[i]); } } if (t[0] == '1') printf("-"); if (K == 1) printf("%.1f\n", ans); if (K == 2) printf("%.2f\n", ans); if (K == 3) printf("%.3f\n", ans); if (K == 4) printf("%.4f\n", ans); if (K == 5) printf("%.5f\n", ans); if (K == 6) printf("%.6f\n", ans); if (K == 7) printf("%.7f\n", ans); if (K == 8) printf("%.8f\n", ans); } }
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
451
2
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pint; typedef vector<int> vint; #define pb push_back #define mp make_pair #define rep(i, n) for (int i = 0; i < (n); i++) template <class T, class U> void chmin(T &t, U f) { if (t > f) t = f; } template <class T, class U> void chmax(T &t, U f) { if (t < f) t = f; } #define int long long int getint(int bit) { return (bit & 0x7ffffff8) >> 7; } int getfrac(int bit) { int ret = 0; int mask = 10000000; for (int i = 6; i >= 0; i--) { if (bit >> i & 1) ret += mask >> (7 - i); } return ret; } void solve() { int val; scanf("%x", &val); if (val >> 31 & 1) cout << "-"; cout << getint(val) << "."; int frac = getfrac(val); if (frac == 0) { cout << 0 << endl; } else { int lost = (int)log10(10000000) - (int)log10(frac); rep(i, lost) cout << 0; while (frac % 10 == 0) frac /= 10; cout << frac << endl; } } signed main() { int Q; cin >> Q; while (Q--) solve(); }
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pint; typedef vector<int> vint; #define pb push_back #define mp make_pair #define rep(i, n) for (int i = 0; i < (n); i++) template <class T, class U> void chmin(T &t, U f) { if (t > f) t = f; } template <class T, class U> void chmax(T &t, U f) { if (t < f) t = f; } #define int long long int getint(int bit) { return (bit & 0x7ffffff8) >> 7; } int getfrac(int bit) { int ret = 0; int mask = 10000000; for (int i = 6; i >= 0; i--) { if (bit >> i & 1) ret += mask >> (7 - i); } return ret; } void solve() { int val; scanf("%x", &val); if (val >> 31 & 1) cout << "-"; cout << getint(val) << "."; int frac = getfrac(val); if (frac == 0) { cout << 0 << endl; } else { int lost = (int)log10(10000000) - (int)log10(frac); rep(i, lost - 1) cout << 0; while (frac % 10 == 0) frac /= 10; cout << frac << endl; } } signed main() { int Q; cin >> Q; while (Q--) solve(); }
[["+", 0, 16, 31, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 16, 31, 2, 3, 4, 0, 16, 12, 13]]
1
309
2
#include <cmath> #include <iomanip> #include <iostream> #include <string> using namespace std; string S; char T[17] = "0123456789abcdef"; int Q; int U[32]; int power[4] = {1, 2, 4, 8}; void Bit(string W) { int c[8], v[32]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 16; j++) { if (W[i] == T[j]) { c[i] = j; } } } int cnt = 0; for (int i = 0; i < 8; i++) { for (int j = 3; j >= 0; j--) { v[cnt] = (c[i] / power[j]) % 2; cnt++; } } for (int i = 0; i < 32; i++) { U[i] = v[31 - i]; } } int Seisu() { int res2 = 0; for (int i = 8; i < 31; i++) { res2 += (1 << (i - 8)) * U[i]; } return res2; } int Shosu() { int res3 = 0; for (int i = 0; i < 8; i++) { res3 += (1 << i) * U[i]; } return res3; } long double solve(string V) { Bit(V); int seisu = Seisu(); int shosu = Shosu(); long double ans = 1.0 * seisu; long double ans2 = 1.0 * shosu; ans += ans2 / 256.0; return ans; } int main() { cin >> Q; for (int i = 0; i < Q; i++) { cin >> S; long double f = solve(S); long long g = f * 200000000; bool ok = false; if (U[31] == 1) { cout << '-'; } for (int i = 18; i >= 9; i--) { long long h = (g / (long long)pow(10, i)) % 10; if (h >= 1) { ok = true; } if (ok == true) { cout << h; } } cout << (g / (long long)pow(10, 8)) % 10; cout << '.'; for (int i = 7; i >= 0; i--) { int h = (g / (long long)pow(10, i)) % 10; if (ok == true || i == 7) { cout << h; } if (g % (long long)(pow(10, i)) == 0) { ok = false; } } cout << endl; } return 0; }
#include <cmath> #include <iomanip> #include <iostream> #include <string> using namespace std; string S; char T[17] = "0123456789abcdef"; int Q; int U[32]; int power[4] = {1, 2, 4, 8}; void Bit(string W) { int c[8], v[32]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 16; j++) { if (W[i] == T[j]) { c[i] = j; } } } int cnt = 0; for (int i = 0; i < 8; i++) { for (int j = 3; j >= 0; j--) { v[cnt] = (c[i] / power[j]) % 2; cnt++; } } for (int i = 0; i < 32; i++) { U[i] = v[31 - i]; } } int Seisu() { int res2 = 0; for (int i = 8; i < 31; i++) { res2 += (1 << (i - 8)) * U[i]; } return res2; } int Shosu() { int res3 = 0; for (int i = 0; i < 8; i++) { res3 += (1 << i) * U[i]; } return res3; } long double solve(string V) { Bit(V); int seisu = Seisu(); int shosu = Shosu(); long double ans = 1.0 * seisu; long double ans2 = 1.0 * shosu; ans += ans2 / 256.0; return ans; } int main() { cin >> Q; for (int i = 0; i < Q; i++) { cin >> S; long double f = solve(S); long long g = f * 200000000; bool ok = false; if (U[31] == 1) { cout << '-'; } for (int i = 18; i >= 9; i--) { long long h = (g / (long long)pow(10, i)) % 10; if (h >= 1) { ok = true; } if (ok == true) { cout << h; } } cout << (g / (long long)pow(10, 8)) % 10; cout << '.'; ok = true; for (int i = 7; i >= 0; i--) { int h = (g / (long long)pow(10, i)) % 10; if (ok == true || i == 7) { cout << h; } if (g % (long long)(pow(10, i)) == 0) { ok = false; } } cout << endl; } return 0; }
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 146], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
591
4
#include <cctype> #include <iomanip> #include <iostream> using namespace std; string getBit(char ch) { int x = isdigit(ch) ? ch - '0' : ch - 'a' + 10; string res = ""; for (int i = 8; i >= 1; i /= 2) { if (x & i) res += "1"; else res += "0"; } return res; } int main() { int Q; cin >> Q; while (Q--) { string ts; cin >> ts; string s; for (int i = 0; i < ts.size(); i++) { s += getBit(ts[i]); } if (s[0] == '1') { cout << "-"; } double sum = 0; for (int i = 0; i < 24; i++) { if (s[i + 1] == '0') continue; sum += (1 << (23 - i)); } bool flg = true; double p = 0.5; for (int i = 0; i < 7; i++, p /= 2) { if (s[25 + i] == '0') continue; flg = false; sum += p; } cout << setprecision(10) << sum; if (flg) { cout << ".0"; } cout << endl; } }
#include <cctype> #include <iomanip> #include <iostream> using namespace std; string getBit(char ch) { int x = isdigit(ch) ? ch - '0' : ch - 'a' + 10; string res = ""; for (int i = 8; i >= 1; i /= 2) { if (x & i) res += "1"; else res += "0"; } return res; } int main() { int Q; cin >> Q; while (Q--) { string ts; cin >> ts; string s; for (int i = 0; i < ts.size(); i++) { s += getBit(ts[i]); } if (s[0] == '1') { cout << "-"; } double sum = 0; for (int i = 0; i < 24; i++) { if (s[i + 1] == '0') continue; sum += (1 << (23 - i)); } bool flg = true; double p = 0.5; for (int i = 0; i < 7; i++, p /= 2) { if (s[25 + i] == '0') continue; flg = false; sum += p; } cout << setprecision(30) << sum; if (flg) { cout << ".0"; } cout << endl; } }
[["-", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13]]
1
290
2
#include <cctype> #include <cstdio> #include <iostream> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; unsigned int num = 0; for (int j = 0; j < 8; j++) { num <<= 4; if (isdigit(s[j])) num += s[j] - '0'; else num += (s[j] - 'a') + 10; } int unit = 5000000; int sum = 0; for (int i = 0; i < 7; i++) { if ((num & (0x40 >> i)) != 0) { sum += unit >> i; } } char buf[8]; sprintf(buf, "%07d", sum); int id = 6; while (buf[id] == '0') id--; buf[id + 1] = '\0'; if ((num & 0x80000000) != 0) cout << "-"; cout << ((num >> 7) & 0x00ffffff) << "." << buf << endl; } return 0; }
#include <cctype> #include <cstdio> #include <iostream> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; unsigned int num = 0; for (int j = 0; j < 8; j++) { num <<= 4; if (isdigit(s[j])) num += s[j] - '0'; else num += (s[j] - 'a') + 10; } int unit = 5000000; int sum = 0; for (int i = 0; i < 7; i++) { if ((num & (0x40 >> i)) != 0) { sum += unit >> i; } } char buf[8]; sprintf(buf, "%07d", sum); int id = 6; while (id > 0 && buf[id] == '0') id--; buf[id + 1] = '\0'; if ((num & 0x80000000) != 0) cout << "-"; cout << ((num >> 7) & 0x00ffffff) << "." << buf << endl; } return 0; }
[["+", 0, 52, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 17, 47], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98]]
1
243
4
#include <cmath> #include <cstdio> using namespace std; typedef unsigned int ui; int main() { int q; scanf("%d", &q); while (q--) { ui bit; scanf("%x", &bit); if (bit >> 31 & 1) putchar('-'); int Seisu = (bit & 0x7FFFFFFF) >> 7; int Syosu = (bit & 0x0000007F) * 78125; double ans = 0.0; int keta; for (int j = 0; j < 7; j++) { if (Syosu & (1 << (6 - j))) { ans += pow(0.5, j + 1); keta = j; } } printf("%.*lf\n", keta + 1, Seisu + ans); } }
#include <cmath> #include <cstdio> using namespace std; typedef unsigned int ui; int main() { int q; scanf("%d", &q); while (q--) { ui bit; scanf("%x", &bit); if (bit >> 31 & 1) putchar('-'); int Seisu = (bit & 0x7FFFFFFF) >> 7; int Syosu = (bit & 0x0000007F); double ans = 0.0; int keta = 0; for (int j = 0; j < 7; j++) { if (Syosu & (1 << (6 - j))) { ans += pow(0.5, j + 1); keta = j; } } printf("%.*lf\n", keta + 1, Seisu + ans); } }
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 48], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
1
160
4
gets $<.map{|l|n=0.0;b=l.hex;30.times{|i|n+=(i<7?0.5**(7-i):2**(i-7))*b[i]};p n*(-1)**b[31]}
gets $<.map{|l|n=0.0;b=l.hex;31.times{|i|n+=(i<7?0.5**(7-i):2**(i-7))*b[i]};p n*(-1)**b[31]}
[["-", 0, 652, 196, 196, 8, 734, 0, 652, 486, 612], ["+", 0, 652, 196, 196, 8, 734, 0, 652, 486, 612]]
4
68
2
gets $<.map{|l|n=0.0;b=l.hex;31.times{|i|n+=(2**(24-i))*b[i]};p n*(-1)**b[31]}
gets $<.map{|l|n=0.0;b=l.hex;31.times{|i|n+=(2**(i-7))*b[i]};p n*(-1)**b[31]}
[["-", 31, 739, 0, 738, 12, 739, 0, 738, 31, 612], ["-", 31, 739, 0, 738, 12, 739, 0, 738, 17, 33], ["+", 31, 739, 0, 738, 12, 739, 0, 738, 17, 33], ["+", 31, 739, 0, 738, 12, 739, 0, 738, 12, 612]]
4
56
4
for i in range(eval(input())): b=format(int(input(),16),"b").zfill(32) a1=0 a2=0.0 for i in range(1,25): a1+=int(b[i])*2**(24-i) for i in range(25,32): a2+=int(b[i])*2**(24-i) print("-1"*int(b[0])+str(a1)+str(a2)[1:])
for i in range(eval(input())): b=format(int(input(),16),"b").zfill(32) a1=0 a2=0.0 for i in range(1,25): a1+=int(b[i])*2**(24-i) for i in range(25,32): a2+=int(b[i])*2**(24-i) print("-"*int(b[0])+str(a1)+str(a2)[1:])
[["-", 0, 657, 31, 657, 31, 657, 31, 557, 0, 6], ["+", 0, 657, 31, 657, 31, 657, 31, 557, 0, 6]]
5
123
2
#include <complex> #include <iostream> #include <math.h> #include <vector> #define EPS 1e-4 #define PI 3.141592 #define EQ(a, b) (abs((a) - (b)) < EPS) using namespace std; typedef complex<double> P; vector<P> house; vector<P> ume, sak, mo; double cross(P v1, P v2) { return v1.real() * v2.imag() - v1.imag() * v2.real(); } bool che(P h, P t, double d, double w, double a) { P v = h - t; if (!(abs(v) < a)) return false; P v1 = P(a * cos((w + d / 2) / 180 * PI), a * sin((w + d / 2) / 180 * PI)); P v2 = P(a * cos((w - d / 2) / 180 * PI), a * sin((w - d / 2) / 180 * PI)); if (cross(v1, v) < 0 && cross(v2, v) > 0) return true; else return false; } int main() { int h, r; while (cin >> h >> r && h && r) { house.clear(); ume.push_back(P(0, 0)); for (int i = 0; i < h; i++) { int x, y; cin >> x >> y; house.push_back(P(x, y)); } int U, M, S, du, dm, ds; cin >> U >> M >> S >> du >> dm >> ds; for (int i = 0; i < U; i++) { int x, y; cin >> x >> y; ume.push_back(P(x, y)); } for (int i = 0; i < M; i++) { int x, y; cin >> x >> y; mo.push_back(P(x, y)); } for (int i = 0; i < S; i++) { int x, y; cin >> x >> y; sak.push_back(P(x, y)); } int data[120]; for (int i = 0; i < 120; i++) data[i] = 0; for (int z = 0; z < r; z++) { int w, a; cin >> w >> a; for (int i = 0; i < house.size(); i++) { bool ok = false; if (che(house[i], ume[0], du, w, a)) ok = true; else continue; for (int j = 1; j < U; j++) { if (che(house[i], ume[j], du, w, a)) ok = false; } for (int j = 0; j < M; j++) { if (che(house[i], mo[j], dm, w, a)) ok = false; } for (int j = 0; j < S; j++) { if (che(house[i], sak[j], ds, w, a)) ok = false; } if (ok) data[i]++; } } int ans = 0; int tmp = -1; for (int i = 0; i < h; i++) { if (ans <= data[i]) { ans = data[i]; tmp = i; } } if (ans == 0) cout << "NA" << endl; else { for (int i = 0; i < h; i++) { if (i == tmp) cout << i + 1; else if (data[i] == ans) cout << i + 1 << " "; } cout << endl; } } }
#include <complex> #include <iostream> #include <math.h> #include <vector> #define EPS 1e-4 #define PI 3.141592 #define EQ(a, b) (abs((a) - (b)) < EPS) using namespace std; typedef complex<double> P; vector<P> house; vector<P> ume, sak, mo; double cross(P v1, P v2) { return v1.real() * v2.imag() - v1.imag() * v2.real(); } bool che(P h, P t, double d, double w, double a) { P v = h - t; if (!(abs(v) < a)) return false; P v1 = P(a * cos((w + d / 2) / 180 * PI), a * sin((w + d / 2) / 180 * PI)); P v2 = P(a * cos((w - d / 2) / 180 * PI), a * sin((w - d / 2) / 180 * PI)); if (cross(v1, v) < 0 && cross(v2, v) > 0) return true; else return false; } int main() { int h, r; while (cin >> h >> r && h && r) { house.clear(); ume.push_back(P(0, 0)); for (int i = 0; i < h; i++) { int x, y; cin >> x >> y; house.push_back(P(x, y)); } int U, M, S, du, dm, ds; cin >> U >> M >> S >> du >> dm >> ds; for (int i = 0; i < U; i++) { int x, y; cin >> x >> y; ume.push_back(P(x, y)); } for (int i = 0; i < M; i++) { int x, y; cin >> x >> y; mo.push_back(P(x, y)); } for (int i = 0; i < S; i++) { int x, y; cin >> x >> y; sak.push_back(P(x, y)); } int data[120]; for (int i = 0; i < 120; i++) data[i] = 0; for (int z = 0; z < r; z++) { int w, a; cin >> w >> a; for (int i = 0; i < house.size(); i++) { bool ok = false; if (che(house[i], ume[0], du, w, a)) ok = true; else continue; for (int j = 1; j <= U; j++) { if (che(house[i], ume[j], du, w, a)) ok = false; } for (int j = 0; j < M; j++) { if (che(house[i], mo[j], dm, w, a)) ok = false; } for (int j = 0; j < S; j++) { if (che(house[i], sak[j], ds, w, a)) ok = false; } if (ok) data[i]++; } } int ans = 0; int tmp = -1; for (int i = 0; i < h; i++) { if (ans <= data[i]) { ans = data[i]; tmp = i; } } if (ans == 0) cout << "NA" << endl; else { for (int i = 0; i < h; i++) { if (i == tmp) cout << i + 1; else if (data[i] == ans) cout << i + 1 << " "; } cout << endl; } } }
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
817
2
#include <algorithm> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <set> #include <vector> using namespace std; typedef long long ll; typedef long double R; typedef complex<R> P; namespace std { bool operator<(P a, P b) { return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b); } bool operator>(P a, P b) { return (b < a); } } // namespace std const R EPS = 1e-10; const R PI = acos((R)(-1)); /* -1 -> neg 0 -> near 0 1 -> pos */ int sgn(R a) { if (a < -EPS) return -1; if (a > EPS) return 1; return 0; } int sgn(R a, R b) { return sgn(b - a); } bool near(P a, P b) { return !sgn(abs(a - b)); } R cross(P a, P b) { return imag(conj(a) * b); } R dot(P a, P b) { return real(conj(a) * b); } R ssqrt(R d) { d = max<R>(0, d); return sqrt(d); } R sacos(R d) { d = max<R>(-1, d); d = min<R>(1, d); return acos(d); } R deg2rad(R x) { return x / 180 * PI; } //?§???????[0, 2*PI)??? R radNorP(R x) { return fmod(fmod(x, 2 * PI) + 2 * PI, 2 * PI); } /** * radian??§???x???[l, r]?????\??£????????????????????\?????? * 0:OFF * 1:IN * 2:ON */ bool inR(R l, R r, R x) { l = radNorP(l); r = radNorP(r); x = radNorP(x); if (!sgn(l, x) || !sgn(r, x)) return 2; if (!sgn(l, r)) return 0; if (sgn(l, r) == 1) { if (sgn(l, x) == 1 && sgn(x, r) == 1) return 1; } else { if (sgn(x, r) == 1 || sgn(l, x) == 1) return 1; } return 0; } struct C { P p; R r; C() {} C(P p, R r) : p(p), r(r) {} }; struct Sec { C c; R l, r; Sec() {} Sec(C c, R l, R r) : c(c), l(l), r(r) {} }; bool crossSecP(const Sec &s, const P &p) { P pp = p - s.c.p; if (sgn(s.c.r, abs(pp)) == 1) return false; return inR(s.l, s.r, arg(pp)) > 0; } const int MN = 200; int h, r, u, m, s; R du, dm, ds; P hp[MN]; P up[MN], mp[MN], sp[MN]; int res[MN]; void calc(R w, R a) { for (int i = 0; i < h; i++) { if (!crossSecP(Sec(C(P(0, 0), a), w - du, w + du), hp[i])) continue; bool f = true; for (int j = 0; j < u; j++) { if (crossSecP(Sec(C(up[j], a), w - du, w + du), hp[i])) f = false; } for (int j = 0; j < m; j++) { if (crossSecP(Sec(C(mp[j], a), w - dm, w + dm), hp[i])) f = false; } for (int j = 0; j < s; j++) { if (crossSecP(Sec(C(sp[j], a), w - ds, w + ds), hp[i])) f = false; } if (!f) continue; res[i]++; } } int main() { while (true) { cin >> h >> r; if (!h && !r) break; for (int i = 0; i < h; i++) { R x, y; cin >> x >> y; hp[i] = P(x, y); } cin >> u >> m >> s >> du >> dm >> ds; du /= 2; dm /= 2; ds /= 2; du = deg2rad(du); dm = deg2rad(dm); ds = deg2rad(ds); for (int i = 0; i < u; i++) { R x, y; cin >> x >> y; up[i] = P(x, y); } for (int i = 0; i < m; i++) { R x, y; cin >> x >> y; mp[i] = P(x, y); } for (int i = 0; i < s; i++) { R x, y; cin >> x >> y; sp[i] = P(x, y); } memset(res, 0, sizeof(res)); for (int i = 0; i < r; i++) { R x, y; cin >> x >> y; calc(deg2rad(x), y); } int ma = 0; for (int i = 0; i < h; i++) { ma = max(ma, res[i]); } if (ma == 0) { cout << "NA" << endl; continue; } vector<int> buf; for (int i = 0; i < h; i++) { if (res[i] == ma) buf.push_back(i); } for (int i = 0; i < (int)buf.size() - 1; i++) { cout << buf[i] << " "; } cout << buf[buf.size() - 1] << endl; } return 0; }
#include <algorithm> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <set> #include <vector> using namespace std; typedef long long ll; typedef long double R; typedef complex<R> P; namespace std { bool operator<(P a, P b) { return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b); } bool operator>(P a, P b) { return (b < a); } } // namespace std const R EPS = 1e-10; const R PI = acos((R)(-1)); /* -1 -> neg 0 -> near 0 1 -> pos */ int sgn(R a) { if (a < -EPS) return -1; if (a > EPS) return 1; return 0; } int sgn(R a, R b) { return sgn(b - a); } bool near(P a, P b) { return !sgn(abs(a - b)); } R cross(P a, P b) { return imag(conj(a) * b); } R dot(P a, P b) { return real(conj(a) * b); } R ssqrt(R d) { d = max<R>(0, d); return sqrt(d); } R sacos(R d) { d = max<R>(-1, d); d = min<R>(1, d); return acos(d); } R deg2rad(R x) { return x / 180 * PI; } //?§???????[0, 2*PI)??? R radNorP(R x) { return fmod(fmod(x, 2 * PI) + 2 * PI, 2 * PI); } /** * radian??§???x???[l, r]?????\??£????????????????????\?????? * 0:OFF * 1:IN * 2:ON */ bool inR(R l, R r, R x) { l = radNorP(l); r = radNorP(r); x = radNorP(x); if (!sgn(l, x) || !sgn(r, x)) return 2; if (!sgn(l, r)) return 0; if (sgn(l, r) == 1) { if (sgn(l, x) == 1 && sgn(x, r) == 1) return 1; } else { if (sgn(x, r) == 1 || sgn(l, x) == 1) return 1; } return 0; } struct C { P p; R r; C() {} C(P p, R r) : p(p), r(r) {} }; struct Sec { C c; R l, r; Sec() {} Sec(C c, R l, R r) : c(c), l(l), r(r) {} }; bool crossSecP(const Sec &s, const P &p) { P pp = p - s.c.p; if (sgn(s.c.r, abs(pp)) == 1) return false; return inR(s.l, s.r, arg(pp)) > 0; } const int MN = 200; int h, r, u, m, s; R du, dm, ds; P hp[MN]; P up[MN], mp[MN], sp[MN]; int res[MN]; void calc(R w, R a) { for (int i = 0; i < h; i++) { if (!crossSecP(Sec(C(P(0, 0), a), w - du, w + du), hp[i])) continue; bool f = true; for (int j = 0; j < u; j++) { if (crossSecP(Sec(C(up[j], a), w - du, w + du), hp[i])) f = false; } for (int j = 0; j < m; j++) { if (crossSecP(Sec(C(mp[j], a), w - dm, w + dm), hp[i])) f = false; } for (int j = 0; j < s; j++) { if (crossSecP(Sec(C(sp[j], a), w - ds, w + ds), hp[i])) f = false; } if (!f) continue; res[i]++; } } int main() { while (true) { cin >> h >> r; if (!h && !r) break; for (int i = 0; i < h; i++) { R x, y; cin >> x >> y; hp[i] = P(x, y); } cin >> u >> m >> s >> du >> dm >> ds; du /= 2; dm /= 2; ds /= 2; du = deg2rad(du); dm = deg2rad(dm); ds = deg2rad(ds); for (int i = 0; i < u; i++) { R x, y; cin >> x >> y; up[i] = P(x, y); } for (int i = 0; i < m; i++) { R x, y; cin >> x >> y; mp[i] = P(x, y); } for (int i = 0; i < s; i++) { R x, y; cin >> x >> y; sp[i] = P(x, y); } memset(res, 0, sizeof(res)); for (int i = 0; i < r; i++) { R x, y; cin >> x >> y; calc(deg2rad(x), y); } int ma = 0; for (int i = 0; i < h; i++) { ma = max(ma, res[i]); } if (ma == 0) { cout << "NA" << endl; continue; } vector<int> buf; for (int i = 0; i < h; i++) { if (res[i] == ma) buf.push_back(i); } for (int i = 0; i < (int)buf.size() - 1; i++) { cout << buf[i] + 1 << " "; } cout << buf[buf.size() - 1] + 1 << endl; } return 0; }
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
1,346
4
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; #define reps(i, f, n) for (int i = f; i < int(n); ++i) #define rep(i, n) reps(i, 0, n) const double PI = acos(-1); bool reach(int x, int y, int w, int a, int d) { if (x * x + y * y > a * a) return false; double arg = atan2(y, x) * 180 / PI - w; if (arg < -180) arg += 360; return abs(arg) * 2 < d; } void func(int H, int R) { vector<pii> house(H); rep(i, H) { cin >> house[i].first >> house[i].second; } int N[3], d[3]; rep(i, 3) cin >> N[i]; rep(i, 3) cin >> d[i]; vector<pii> tree[3]; rep(i, 3) { tree[i].resize(N[i]); rep(j, N[i]) { cin >> tree[i][j].first >> tree[i][j].second; } } vi cnt(H); rep(i, R) { int w, a; cin >> w >> a; rep(j, H) { bool ok = reach(house[j].first, house[j].second, w, a, d[0]); rep(k, 3) rep(l, N[k]) { ok &= !reach(house[j].first - tree[k][l].first, house[j].second - tree[k][l].second, w, a, d[k]); } if (ok) cnt[j]++; } } int maxi = *max_element(cnt.begin(), cnt.end()); if (maxi == 0) { cout << "NA" << endl; return; } bool first = true; rep(i, H) { if (cnt[i] == maxi) { cout << (first ? "" : " ") << i; first = false; } } cout << endl; } int main() { int H, R; while (cin >> H >> R, H) { func(H, R); } }
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; #define reps(i, f, n) for (int i = f; i < int(n); ++i) #define rep(i, n) reps(i, 0, n) const double PI = acos(-1); bool reach(int x, int y, int w, int a, int d) { if (x * x + y * y > a * a) return false; double arg = atan2(y, x) * 180 / PI - w; if (arg < -180) arg += 360; return abs(arg) * 2 < d; } void func(int H, int R) { vector<pii> house(H); rep(i, H) { cin >> house[i].first >> house[i].second; } int N[3], d[3]; rep(i, 3) cin >> N[i]; rep(i, 3) cin >> d[i]; vector<pii> tree[3]; rep(i, 3) { tree[i].resize(N[i]); rep(j, N[i]) { cin >> tree[i][j].first >> tree[i][j].second; } } vi cnt(H); rep(i, R) { int w, a; cin >> w >> a; rep(j, H) { bool ok = reach(house[j].first, house[j].second, w, a, d[0]); rep(k, 3) rep(l, N[k]) { ok &= !reach(house[j].first - tree[k][l].first, house[j].second - tree[k][l].second, w, a, d[k]); } if (ok) cnt[j]++; } } int maxi = *max_element(cnt.begin(), cnt.end()); if (maxi == 0) { cout << "NA" << endl; return; } bool first = true; rep(i, H) { if (cnt[i] == maxi) { cout << (first ? "" : " ") << i + 1; first = false; } } cout << endl; } int main() { int H, R; while (cin >> H >> R, H) { func(H, R); } }
[["+", 64, 9, 0, 1, 0, 16, 12, 16, 17, 72], ["+", 64, 9, 0, 1, 0, 16, 12, 16, 12, 13]]
1
540
2
import java.util.*; class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int N = Integer.parseInt(s.next()); int Q = Integer.parseInt(s.next()); TreeSet<Integer> set = new TreeSet<Integer>(); for (int i = 0; i < N; i++) { int c = Integer.parseInt(s.next()); set.add(c); } int max_val = Collections.max(set); for (int i = 0; i < Q; i++) { int q = Integer.parseInt(s.next()); int ans = 0; for (int j = q; j <= max_val; j += q) { Integer v = set.lower(j); if (v != null) ans = Math.max(ans, v % q); } System.out.println(ans); } } }
import java.util.*; class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int N = Integer.parseInt(s.next()); int Q = Integer.parseInt(s.next()); TreeSet<Integer> set = new TreeSet<Integer>(); for (int i = 0; i < N; i++) { int c = Integer.parseInt(s.next()); set.add(c); } int max_val = Collections.max(set); for (int i = 0; i < Q; i++) { int q = Integer.parseInt(s.next()); int ans = max_val % q; for (int j = q; j <= max_val; j += q) { Integer v = set.lower(j); if (v != null) ans = Math.max(ans, v % q); } System.out.println(ans); } } }
[["-", 0, 7, 8, 196, 0, 503, 49, 200, 51, 499], ["+", 8, 196, 0, 503, 49, 200, 51, 16, 31, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 16, 17, 109], ["+", 8, 196, 0, 503, 49, 200, 51, 16, 12, 22]]
3
213
4
#include <algorithm> #include <iostream> #include <set> using namespace std; int main() { int N, Q; cin >> N >> Q; set<int, greater<int>> values; for (int i = 0; i < N; i++) { int v; cin >> v; values.insert(v); } int max_value = *values.begin(); for (int i = 0; i < Q; i++) { int q; cin >> q; int ans = max_value % q; for (int j = q; j < max_value; j += q) { set<int, greater<int>>::iterator it = values.upper_bound(j); if (it == values.end()) continue; ans = max(ans, *it % q); } cout << ans << endl; } return 0; }
#include <algorithm> #include <iostream> #include <set> using namespace std; int main() { int N, Q; cin >> N >> Q; set<int, greater<int>> values; for (int i = 0; i < N; i++) { int v; cin >> v; values.insert(v); } int max_value = *values.begin(); for (int i = 0; i < Q; i++) { int q; cin >> q; int ans = max_value % q; for (int j = q; j <= max_value; j += q) { set<int, greater<int>>::iterator it = values.upper_bound(j); if (it == values.end()) continue; ans = max(ans, *it % q); } cout << ans << endl; } return 0; }
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
178
2
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef tuple<int, int> duo; #define TT template <typename T> #define ET(T) typename T::value_type TT inline T sq(T x) { return x * x; } TT inline T In() { T x; cin >> x; return x; } TT inline int ubnd(T &v, ET(T) x) { return upper_bound(begin(v), end(v), x) - begin(v); } TT inline int lbnd(T &v, ET(T) x) { return lower_bound(begin(v), end(v), x) - begin(v); } TT inline void sort(T &v) { sort(begin(v), end(v)); } TT inline void revs(T &v) { reverse(begin(v), end(v)); } TT inline void uniq(T &v) { sort(v); v.erase(unique(begin(v), end(v)), end(v)); } TT inline void inpt(T &v, int n, function<ET(T)()> f = In<ET(T)>) { for (v.reserve(n); n--; v.emplace_back(f())) ; } TT inline void show(T &v, string d = " ", string e = "\n") { int i = 0; for (auto &x : v) i++ && (cout << d), cout << x; cout << e; } #undef TT #undef ET inline void fast_io() { ios::sync_with_stdio(0); cin.tie(0); } inline int in() { int x; scanf("%d", &x); return x; } inline string instr() { string x; cin >> x; return x; } inline ll pow_mod(ll a, ll k, ll m) { ll r = 1; for (; k > 0; a = a * a % m, k >>= 1) if (k & 1) r = r * a % m; return r; } inline ll mod_inv(ll a, ll p) { return pow_mod(a, p - 2, p); } const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; const int Mod = 1000000000; int main() { fast_io(); vector<int> c, q; int N, Q; cin >> N >> Q; inpt(c, N); inpt(q, Q); sort(c); revs(c); int mbucket[300001] = {}; for (const auto &ci : c) { for (int x = ci + 1; x <= 300000; x++) { if (mbucket[x]) break; mbucket[x] = ci; } } for (const auto &qi : q) { int maxi = 0; for (int x = qi - 1; x <= 300000; x += qi) { maxi = max(maxi, mbucket[x] % qi); } cout << maxi << "\n"; } return (0); } // priority_queue queue deque front top push pop map set stringstream // max_element min_element insert count find get tie make_tuple
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef tuple<int, int> duo; #define TT template <typename T> #define ET(T) typename T::value_type TT inline T sq(T x) { return x * x; } TT inline T In() { T x; cin >> x; return x; } TT inline int ubnd(T &v, ET(T) x) { return upper_bound(begin(v), end(v), x) - begin(v); } TT inline int lbnd(T &v, ET(T) x) { return lower_bound(begin(v), end(v), x) - begin(v); } TT inline void sort(T &v) { sort(begin(v), end(v)); } TT inline void revs(T &v) { reverse(begin(v), end(v)); } TT inline void uniq(T &v) { sort(v); v.erase(unique(begin(v), end(v)), end(v)); } TT inline void inpt(T &v, int n, function<ET(T)()> f = In<ET(T)>) { for (v.reserve(n); n--; v.emplace_back(f())) ; } TT inline void show(T &v, string d = " ", string e = "\n") { int i = 0; for (auto &x : v) i++ && (cout << d), cout << x; cout << e; } #undef TT #undef ET inline void fast_io() { ios::sync_with_stdio(0); cin.tie(0); } inline int in() { int x; scanf("%d", &x); return x; } inline string instr() { string x; cin >> x; return x; } inline ll pow_mod(ll a, ll k, ll m) { ll r = 1; for (; k > 0; a = a * a % m, k >>= 1) if (k & 1) r = r * a % m; return r; } inline ll mod_inv(ll a, ll p) { return pow_mod(a, p - 2, p); } const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; const int Mod = 1000000000; int main() { fast_io(); vector<int> c, q; int N, Q; cin >> N >> Q; inpt(c, N); inpt(q, Q); sort(c); revs(c); int mbucket[300001] = {}; for (const auto &ci : c) { for (int x = ci + 1; x <= 300000; x++) { if (mbucket[x]) break; mbucket[x] = ci; } } for (const auto &qi : q) { int maxi = 0; for (int x = qi; x <= 300000; x += qi) { maxi = max(maxi, mbucket[x] % qi); } cout << maxi << "\n"; } return (0); } // priority_queue queue deque front top push pop map set stringstream // max_element min_element insert count find get tie make_tuple
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 33], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
710
2
#include <algorithm> #include <cstdio> #define M 50 using namespace std; int n, q; int c[300100], x; int main() { scanf("%d%d", &n, &q); int lim = 0; for (int i = 0; i < n; i++) { scanf("%d", &c[i]); lim = max(lim, c[i]); } sort(c, c + n); int m[M] = {0}; for (int i = 1; i <= M; i++) { for (int j = 0; j < n; j++) m[i] = max(m[i], c[j] % i); } for (int i = 0; i < q; i++) { scanf("%d", &x); if (x <= M) printf("%d\n", m[x]); else { int res = 0; for (int j = 1; j * x <= lim; j++) { int tmp = lower_bound(c, c + n, j * x) - c; if (tmp) res = max(res, c[tmp - 1] % x); } printf("%d\n", res); } } }
#include <algorithm> #include <cstdio> #define M 50 using namespace std; int n, q; int c[300100], x; int main() { scanf("%d%d", &n, &q); int lim = 0; for (int i = 0; i < n; i++) { scanf("%d", &c[i]); lim = max(lim, c[i]); } sort(c, c + n); int m[M + 1] = {0}; for (int i = 1; i <= M; i++) { for (int j = 0; j < n; j++) m[i] = max(m[i], c[j] % i); } for (int i = 0; i < q; i++) { scanf("%d", &x); if (x <= M) printf("%d\n", m[x]); else { int res = 0; for (int j = 1; j * x <= lim; j++) { int tmp = lower_bound(c, c + n, j * x) - c; if (tmp) res = max(res, c[tmp - 1] % x); } printf("%d\n", res); } } }
[["+", 0, 43, 49, 50, 49, 80, 81, 16, 17, 72], ["+", 0, 43, 49, 50, 49, 80, 81, 16, 12, 13]]
1
277
2
#include <algorithm> #include <cstdio> #include <vector> using namespace std; int arr[300002]; int mo[300001]; int main() { int n, q; scanf("%d%d", &n, &q); for (int i = 0; i < n; i++) scanf("%d", &arr[i + 1]); arr[0] = 0; sort(arr, arr + n + 1); arr[n + 1] = 300001; for (int i = 0; i < n + 1; i++) { for (int j = arr[i]; j < arr[i + 1]; j++) mo[j] = arr[i]; } while (q--) { int t; scanf("%d", &t); int ma = 0; for (int i = t; i <= 300000; i += t) ma = max(ma, mo[i] % t); printf("%d\n", ma); } return 0; }
#include <algorithm> #include <cstdio> #include <vector> using namespace std; int arr[300002]; int mo[300001]; int main() { int n, q; scanf("%d%d", &n, &q); for (int i = 0; i < n; i++) scanf("%d", &arr[i + 1]); arr[0] = 0; sort(arr, arr + n + 1); arr[n + 1] = 300001; for (int i = 0; i < n + 1; i++) { for (int j = arr[i]; j < arr[i + 1]; j++) mo[j] = arr[i]; } while (q--) { int t; scanf("%d", &t); int ma = 0; for (int i = t; i <= 300000; i += t) ma = max(ma, mo[i - 1] % t); printf("%d\n", ma); } return 0; }
[["+", 0, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 16, 31, 69, 341, 342, 0, 16, 12, 13]]
1
219
2
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <string> #include <utility> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define INF 1000000000007 using namespace std; typedef long long int ll; int main() { int n, q; cin >> n >> q; vector<int> c(n); for (int i = 0; i < n; i++) cin >> c[i]; sort(c.begin(), c.end()); // for(int i=0;i<n;i++) cout << c[i]; for (int i = 0; i < q; i++) { int query; cin >> query; // cout << query <<" "; int flag = 1; int ans = c[n - 1] % query; while (flag * query <= c[n - 1]) { int lb = 0, ub = n; // cout << query<<" "<<lb<<"|"; while (abs(lb - ub) > 1) { // cout << lb <<" "<<ub<<endl; int mean = (lb + ub) / 2; if (c[mean] < flag * query) { lb = mean; } if (c[mean] > flag * query) { ub = mean; } if (c[mean] == flag * query) { ub = mean; lb = mean; } } ans = max(ans, c[lb] % query); flag++; } cout << ans << endl; } }
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <string> #include <utility> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define INF 1000000000007 using namespace std; typedef long long int ll; int main() { int n, q; cin >> n >> q; vector<int> c(n); for (int i = 0; i < n; i++) cin >> c[i]; sort(c.begin(), c.end()); for (int i = 0; i < q; i++) { int query; cin >> query; int flag = 1; int ans = c[n - 1] % query; while (flag * query <= c[n - 1]) { int lb = 0, ub = n; while (abs(lb - ub) > 1) { int mean = (lb + ub) / 2; if (c[mean] < flag * query - 1) { lb = mean; } if (c[mean] > flag * query - 1) { ub = mean; } if (c[mean] == flag * query - 1) { ub = mean; lb = mean; } } ans = max(ans, c[lb] % query); flag++; } cout << ans << endl; } }
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
271
6
#include <cstdio> #define MAX_N 300000 #define MAX_C 300000 int main() { int N, Q; scanf("%d %d\n", &N, &Q); int card[MAX_N]; bool has_card[MAX_C + 1]; for (int i = 0; i < N; i++) { scanf("%d", &card[i]); // printf("card %d ", card[i]); } for (int i = 0; i <= MAX_C; i++) { has_card[i] = false; } for (int i = 0; i < N; i++) { has_card[card[i]] = true; } // printf("\n"); for (int i = 0; i < Q; i++) { int q; scanf(" %d", &q); // printf("q = %d\n", q); bool found = false; for (int init = q - 1; init > 0; init--) { for (int j = init; j < MAX_C; j += q) { if (has_card[j]) { printf("%d\n", init); found = true; break; } } if (found) { break; } } } return 0; }
#include <cstdio> #define MAX_N 300000 #define MAX_C 300000 int main() { int N, Q; scanf("%d %d\n", &N, &Q); int card[MAX_N]; bool has_card[MAX_C + 1]; for (int i = 0; i < N; i++) { scanf("%d", &card[i]); // printf("card %d ", card[i]); } for (int i = 0; i <= MAX_C; i++) { has_card[i] = false; } for (int i = 0; i < N; i++) { has_card[card[i]] = true; } // printf("\n"); for (int i = 0; i < Q; i++) { int q; scanf(" %d", &q); // printf("q = %d\n", q); bool found = false; for (int init = q - 1; init >= 0; init--) { for (int j = init; j < MAX_C; j += q) { if (has_card[j]) { printf("%d\n", init); found = true; break; } } if (found) { break; } } } return 0; }
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 20]]
1
233
2
#include <iostream> using namespace std; int main() { int n, q, last[300001]; cin >> n >> q; for (int i = 0; i <= 300000; i++) last[i] = -1; for (int i = 0; i < n; i++) { int c; cin >> c; last[c] = c; } last[0] = 0; for (int i = 1; i <= 300000; i++) { if (last[i] == -1) last[i] = last[i - 1]; } for (int i = 0; i < q; i++) { int t, ma = 0; cin >> t; for (int j = 0; j <= 300000; j += t) ma = max(ma, last[j] % t); cout << ma << endl; } return 0; }
#include <iostream> using namespace std; int main() { int n, q, last[300001]; cin >> n >> q; for (int i = 0; i <= 300000; i++) last[i] = -1; for (int i = 0; i < n; i++) { int c; cin >> c; last[c] = c; } last[0] = 0; for (int i = 1; i <= 300000; i++) { if (last[i] == -1) last[i] = last[i - 1]; } for (int i = 0; i < q; i++) { int t, ma = 0; cin >> t; for (int j = t - 1; j <= 300000; j += t) ma = max(ma, last[j] % t); cout << ma << endl; } return 0; }
[["-", 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, 33], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
188
4
// Modular Query // c[i] = i 以下のカードのうち最大のカード // wrong answer // 1/5 #include <iostream> using namespace std; int main() { int N, Q, q; int c[300001] = {0}; cin >> N >> Q; while (N-- > 0) { int i; cin >> i; c[i] = i; } for (int i = 1; i < 300001; i++) { if (!c[i]) c[i] = c[i - 1]; } while (Q-- > 0) { int res = 0; cin >> q; for (int i = q; i < 300001; i += q) { res = max(res, c[i] % q); } cout << res << endl; } }
// Modular Query // c[i] = i 以下のカードのうち最大のカード // wrong answer // 1/5 #include <iostream> using namespace std; int main() { int N, Q, q; int c[300001] = {0}; cin >> N >> Q; while (N-- > 0) { int i; cin >> i; c[i] = i; } for (int i = 1; i < 300001; i++) { if (!c[i]) c[i] = c[i - 1]; } while (Q-- > 0) { int res = 0; cin >> q; for (int i = q - 1; i < 300001; i += q) { res = max(res, c[i] % q); } cout << res << endl; } }
[["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 33], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
153
2
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define FOR(i, a, n) for (int i = (a); i < (n); i++) #define MP make_pair #define all(s) (s).begin(), (s).end() #define rev(s) (s).rbegin(), (s).rend() #define X first #define Y second using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> P; int main() { int n, Q; cin >> n >> Q; vector<int> c(n); rep(i, n) cin >> c[i]; c.push_back(0); sort(all(c)); int MAX = c[n - 1]; while (Q--) { int q; cin >> q; int ans = 0; for (int i = q; i <= 300000; i += q) { ans = max(ans, *(upper_bound(all(c), i) - 1) % q); if (MAX <= i) break; } cout << ans << endl; } return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define FOR(i, a, n) for (int i = (a); i < (n); i++) #define MP make_pair #define all(s) (s).begin(), (s).end() #define rev(s) (s).rbegin(), (s).rend() #define X first #define Y second using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> P; int main() { int n, Q; cin >> n >> Q; vector<int> c(n); rep(i, n) cin >> c[i]; c.push_back(0); sort(all(c)); int MAX = c[c.size() - 1]; while (Q--) { int q; cin >> q; int ans = 0; for (int i = q; i <= 300000; i += q) { ans = max(ans, *(lower_bound(all(c), i) - 1) % q); if (MAX <= i) break; } cout << ans << endl; } return 0; }
[["-", 49, 50, 51, 69, 341, 342, 0, 16, 31, 22], ["+", 341, 342, 0, 16, 31, 2, 63, 118, 28, 22], ["+", 341, 342, 0, 16, 31, 2, 63, 118, 17, 131], ["+", 341, 342, 0, 16, 31, 2, 63, 118, 119, 120], ["+", 341, 342, 0, 16, 31, 2, 3, 4, 0, 24], ["+", 341, 342, 0, 16, 31, 2, 3, 4, 0, 25], ["-", 31, 66, 28, 23, 0, 16, 31, 2, 63, 22], ["+", 31, 66, 28, 23, 0, 16, 31, 2, 63, 22]]
1
232
8
#include <iostream> using namespace std; #define rep(i, n) for (int i = 0; i < int(n); ++i) int main() { int n, q; cin >> n >> q; int c[300001]; fill(c, c + 300001, 0); rep(i, n) { int cc; cin >> cc; c[cc] = cc; } rep(i, 300000) c[i + 1] = max(c[i], c[i + 1]); rep(i, q) { int a; cin >> a; int res = 0; for (int j = 0; j <= 300000; j += a) res = max(res, c[j] % a); res = max(res, c[300000] % a); cout << res << endl; } }
#include <iostream> using namespace std; #define rep(i, n) for (int i = 0; i < int(n); ++i) int main() { int n, q; cin >> n >> q; int c[300001]; fill(c, c + 300001, 0); rep(i, n) { int cc; cin >> cc; c[cc] = cc; } rep(i, 300000) c[i + 1] = max(c[i], c[i + 1]); rep(i, q) { int a; cin >> a; int res = 0; for (int j = a - 1; j <= 300000; j += a) res = max(res, c[j] % a); res = max(res, c[300000] % a); cout << res << endl; } }
[["-", 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, 33], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
167
4
#include <stdio.h> typedef long long ll; const ll MOD = 1000000007; ll fact[112345] = {1}; ll bit[112345]; int str[112345]; int main() { for (int i = 1; i < 112345; ++i) fact[i] = fact[i - 1] * i % MOD; for (;;) { int n; scanf("%d", &n); if (!n) return 0; for (int i = 0; i < n; ++i) str[i] = i; int r; scanf("%d", &r); for (int i = 0; i < r; ++i) { int s, t; scanf("%d%d", &s, &t); int tmp = str[s - 1]; str[s - 1] = str[t - 1]; str[t - 1] = tmp; } // for(int i = 0; i < n; ++i) printf("%d ", str[i]); putchar('\n'); for (int i = 0; i < n; ++i) bit[i] = 0; ll ans = 0; for (int i = 0; i < n; ++i) { ll count = str[i]; for (int j = str[i] + 1; j; j -= j & -j) count -= bit[j]; ans = (ans + fact[n - i - 1] * count) % MOD; for (int j = str[i] + 1; j <= n; j += j & -j) ++bit[j]; } printf("%lld\n", ans); } }
#include <stdio.h> typedef long long ll; const ll MOD = 1000000007; ll fact[112345] = {1}; ll bit[112345]; int str[112345]; int main() { for (int i = 1; i < 112345; ++i) fact[i] = fact[i - 1] * i % MOD; for (;;) { int n; scanf("%d", &n); if (!n) return 0; for (int i = 0; i < n; ++i) str[i] = i; int r; scanf("%d", &r); for (int i = 0; i < r; ++i) { int s, t; scanf("%d%d", &s, &t); int tmp = str[s - 1]; str[s - 1] = str[t - 1]; str[t - 1] = tmp; } // for(int i = 0; i < n; ++i) printf("%d ", str[i]); putchar('\n'); for (int i = 1; i <= n; ++i) bit[i] = 0; ll ans = 0; for (int i = 0; i < n; ++i) { ll count = str[i]; for (int j = str[i] + 1; j; j -= j & -j) count -= bit[j]; ans = (ans + fact[n - i - 1] * count) % MOD; for (int j = str[i] + 1; j <= n; j += j & -j) ++bit[j]; } printf("%lld\n", ans); } }
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
0
337
4
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int p; int ppow(int a) { int b = p - 2, res = 1; while (b) { if (b & 1) res = (res * a) % p; a = (a * a) % p; b >>= 1; } return res; } int o2(string &s, int &i); int o3(string &s, int &i); int num(string &s, int &i, int p); int o1(string &s, int &i) { int v = o2(s, i); if (v == -1) return -1; while (s[i] == '+' || s[i] == '-') { char op = s[i++]; int v2 = o2(s, i); if (v2 == -1) return -1; if (op == '+') (v += v2) %= p; else v = (v + p - v2) % p; } return v; } int o2(string &s, int &i) { int v = o3(s, i); if (v == -1) return -1; while (s[i] == '*' || s[i] == '/') { char op = s[i++]; int v2 = o3(s, i); if (v2 == -1) return -1; if (op == '*') (v *= v2) %= p; else if (v2 == 0) return -1; else v = v * ppow(v2); } return v; } int o3(string &s, int &i) { if (isdigit(s[i])) return num(s, i, p); i++; int res = o1(s, i); i++; return res; } int num(string &s, int &i, int p) { int n = 0; while (isdigit(s[i])) n = (n * 10 + s[i++] - '0') % p; return n; } int main() { string s; while (getline(cin, s), s != "0:") { int i = 0; p = num(s, i, INT_MAX); string t; for (i++; i < s.size(); i++) { if (s[i] != ' ') t += s[i]; } i = 0; int ret = o1(t, i); if (ret == -1) puts("NG"); else cout << t << " = " << ret << " (mod " << p << ")" << endl; } }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int p; int ppow(int a) { int b = p - 2, res = 1; while (b) { if (b & 1) res = (res * a) % p; a = (a * a) % p; b >>= 1; } return res; } int o2(string &s, int &i); int o3(string &s, int &i); int num(string &s, int &i, int p); int o1(string &s, int &i) { int v = o2(s, i); if (v == -1) return -1; while (s[i] == '+' || s[i] == '-') { char op = s[i++]; int v2 = o2(s, i); if (v2 == -1) return -1; if (op == '+') (v += v2) %= p; else v = (v + p - v2) % p; } return v; } int o2(string &s, int &i) { int v = o3(s, i); if (v == -1) return -1; while (s[i] == '*' || s[i] == '/') { char op = s[i++]; int v2 = o3(s, i); if (v2 == -1) return -1; if (op == '*') (v *= v2) %= p; else if (v2 == 0) return -1; else v = (v * ppow(v2)) % p; } return v; } int o3(string &s, int &i) { if (isdigit(s[i])) return num(s, i, p); i++; int res = o1(s, i); i++; return res; } int num(string &s, int &i, int p) { int n = 0; while (isdigit(s[i])) n = (n * 10 + s[i++] - '0') % p; return n; } int main() { string s; while (getline(cin, s), s != "0:") { int i = 0; p = num(s, i, INT_MAX); string t; for (i++; i < s.size(); i++) { if (s[i] != ' ') t += s[i]; } i = 0; int ret = o1(t, i); if (ret == -1) puts("NG"); else cout << t << " = " << ret << " (mod " << p << ")" << endl; } }
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 12, 2, 3, 4, 0, 25], ["+", 75, 76, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 75, 76, 0, 1, 0, 11, 12, 16, 12, 22]]
1
586
4
#include <stdio.h> #include <string.h> int main() { int m[2][6] = {{1, -1, 1, 4, 5, 2}, {2, 3, -1, 5, 2, 1}}; char s[101]; int n, i, a; while (1) { scanf("%s", s); if (s[0] == '#') break; n = 0; a = 1; for (i = 0; i < strlen(s); i++) { n = m[s[i] - '0'][n]; if (n == -1) { a = 0; break; } } if (a && n == 5) printf("Yes\n"); else printf("NO\n"); } return 0; }
#include <stdio.h> #include <string.h> int main() { int m[2][6] = {{1, -1, 1, 4, 5, 2}, {2, 3, -1, 5, 2, 1}}; char s[101]; int n, i, a; while (1) { scanf("%s", s); if (s[0] == '#') break; n = 0; a = 1; for (i = 0; i < strlen(s); i++) { n = m[s[i] - '0'][n]; if (n == -1) { a = 0; break; } } if (a && n == 5) printf("Yes\n"); else printf("No\n"); } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
175
2
#include <stdio.h> int main() { char s[110]; int i, d, m[7][2] = {{1, 2}, {6, 3}, {1, 6}, {4, 5}, {5, 2}, {2, 5}, {6, 6}}; while (scanf("%s", s), s[0] - '#') { for (i = d = 0; s[i]; i++) d = m[d][s[i] - '0']; if (d - 5) printf("No\n"); else printf("Yes\n"); } return 0; }
#include <stdio.h> int main() { char s[110]; int i, d, m[7][2] = {{1, 2}, {6, 3}, {1, 6}, {4, 5}, {5, 2}, {2, 1}, {6, 6}}; while (scanf("%s", s), s[0] - '#') { for (i = d = 0; s[i]; i++) d = m[d][s[i] - '0']; if (d - 5) printf("No\n"); else printf("Yes\n"); } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13]]
0
152
2
#include <stdio.h> #include <string.h> int main(void) { char road[150]; int str; int i; char aka; while (scanf("%s", road)) { if (road[0] == '#') { break; } str = strlen(road); aka = 'A'; for (i = 0; i < str; i++) { switch (aka) { case 'A': if (road[i] == '0') { aka = 'X'; } else { aka = 'Y'; } break; case 'X': if (road[i] == '0') { aka = 0; } else { aka = 'Z'; } break; case 'Y': if (road[i] == '0') { aka = 'X'; } else { aka = 0; } break; case 'Z': if (road[i] == '0') { aka = 'W'; } else { aka = 'B'; } break; case 'W': if (road[i] == '0') { aka = 'B'; } else { aka = 'Y'; } break; case 'B': if (road[i] == '0') { aka = 'Y'; } else { aka = 'X'; } break; default: i = str; break; } } if (aka == 'B') { printf("Yes\n"); } else { printf("NO\n"); } } return (0); }
#include <stdio.h> #include <string.h> int main(void) { char road[150]; int str; int i; char aka; while (scanf("%s", road)) { if (road[0] == '#') { break; } str = strlen(road); aka = 'A'; for (i = 0; i < str; i++) { switch (aka) { case 'A': if (road[i] == '0') { aka = 'X'; } else { aka = 'Y'; } break; case 'X': if (road[i] == '0') { aka = 0; } else { aka = 'Z'; } break; case 'Y': if (road[i] == '0') { aka = 'X'; } else { aka = 0; } break; case 'Z': if (road[i] == '0') { aka = 'W'; } else { aka = 'B'; } break; case 'W': if (road[i] == '0') { aka = 'B'; } else { aka = 'Y'; } break; case 'B': if (road[i] == '0') { aka = 'Y'; } else { aka = 'X'; } break; default: i = str; break; } } if (aka == 'B') { printf("Yes\n"); } else { printf("No\n"); } } return (0); }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
336
2
#include <cstring> #include <iostream> using namespace std; string removedFirst(string str) { string ans; if (str.length() == 1) { return ans; } else { for (int i = 1; i < str.length(); i++) { ans += str[i]; } return ans; } } int main() { string str; getline(cin, str); while (str != "#") { char where = 'A'; while (str.length() != 0) { char oldWhere = where; switch (where) { case 'A': if (str[0] == '0') { where = 'X'; } else { where = 'Y'; } break; case 'B': if (str[0] == '0') { where = 'Y'; } else { where = 'X'; } break; case 'X': if (str[0] == '1') { where = 'Z'; } break; case 'Y': if (str[0] == '0') { where = 'X'; } break; case 'Z': if (str[0] == '0') { where = 'W'; } else { where = 'B'; } break; case 'W': if (str[0] == '0') { where = 'B'; } else { where = 'Y'; } } str = removedFirst(str); if (where == oldWhere) { where = 'N'; str.clear(); } } // char tmp = 'B'; if (where == 'B') { cout << "YES" << endl; } else { cout << "NO" << endl; } getline(cin, str); } }
#include <cstring> #include <iostream> using namespace std; string removedFirst(string str) { string ans; if (str.length() == 1) { return ans; } else { for (int i = 1; i < str.length(); i++) { ans += str[i]; } return ans; } } int main() { string str; getline(cin, str); while (str != "#") { char where = 'A'; while (str.length() != 0) { char oldWhere = where; switch (where) { case 'A': if (str[0] == '0') { where = 'X'; } else { where = 'Y'; } break; case 'B': if (str[0] == '0') { where = 'Y'; } else { where = 'X'; } break; case 'X': if (str[0] == '1') { where = 'Z'; } break; case 'Y': if (str[0] == '0') { where = 'X'; } break; case 'Z': if (str[0] == '0') { where = 'W'; } else { where = 'B'; } break; case 'W': if (str[0] == '0') { where = 'B'; } else { where = 'Y'; } } str = removedFirst(str); if (where == oldWhere) { where = 'N'; str.clear(); } } if (where == 'B') { cout << "Yes" << endl; } else { cout << "No" << endl; } getline(cin, str); } }
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
377
4
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; char getNext(char now, int way) { switch (now) { case 'a': return way ? 'y' : 'x'; case 'x': return way ? 'z' : 'o'; case 'z': return way ? 'b' : 'w'; case 'b': return way ? 'x' : 'y'; case 'w': return way ? 'y' : 'b'; case 'y': return way ? 'o' : 'x'; default: return 'o'; } } int main() { string root = ""; while (cin >> root && root != "#") { char start = 'a'; for (int i = 0; i < root.size(); i++) { start = getNext(start, (int)root[i] - '0'); if (start == 'o') break; } if (start == 'b') cout << "YES" << endl; else cout << "NO" << endl; } return 0; }
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; char getNext(char now, int way) { switch (now) { case 'a': return way ? 'y' : 'x'; case 'x': return way ? 'z' : 'o'; case 'z': return way ? 'b' : 'w'; case 'b': return way ? 'x' : 'y'; case 'w': return way ? 'y' : 'b'; case 'y': return way ? 'o' : 'x'; default: return 'o'; } } int main() { string root = ""; while (cin >> root && root != "#") { char start = 'a'; for (int i = 0; i < root.size(); i++) { start = getNext(start, (int)root[i] - '0'); if (start == 'o') break; } if (start == 'b') cout << "Yes" << endl; else cout << "No" << endl; } return 0; }
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
242
4
#include <cstdio> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { const int to[7][2] = {{1, 3}, {6, 2}, {4, 5}, {1, 6}, {5, 3}, {3, 1}}; while (1) { char s[128]; scanf("%s", s); if (s[0] == '#') break; int u = 0; for (int i = 0; s[i]; i++) u = to[u][s[i] - '0']; puts(u == 5 ? "Yes" : "No"); } return 0; }
#include <cstdio> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { const int to[7][2] = {{1, 3}, {6, 2}, {4, 5}, {1, 6}, {5, 3}, {3, 1}, {6, 6}}; while (1) { char s[128]; scanf("%s", s); if (s[0] == '#') break; int u = 0; for (int i = 0; s[i]; i++) u = to[u][s[i] - '0']; puts(u == 5 ? "Yes" : "No"); } return 0; }
[["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 21], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 45], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 21], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 46]]
1
157
6
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #define reep(i, n, m) for (int i = (n); i < (m); i++) #define rep(i, n) reep(i, 0, n) using namespace std; char road[100][2] = {0}; int main() { string str; road['A'][0] = 'X'; road['A'][1] = 'Y'; road['X'][1] = 'Z'; road['Z'][0] = 'W'; road['Z'][1] = 'B'; road['B'][0] = 'Y'; road['B'][1] = 'X'; road['W'][0] = 'B'; road['W'][1] = 'Y'; road['Y'][0] = 'X'; while (cin >> str, str != "#") { char now_town = 'A'; bool flg = true; rep(i, str.length()) { int d = str[i] - '0'; now_town = road[now_town][d]; if (now_town == 0) { flg = false; break; } } if (now_town != 'B') { flg = false; } if (flg) { puts("YES"); } else { puts("NO"); } } return 0; }
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #define reep(i, n, m) for (int i = (n); i < (m); i++) #define rep(i, n) reep(i, 0, n) using namespace std; char road[100][2] = {0}; int main() { string str; road['A'][0] = 'X'; road['A'][1] = 'Y'; road['X'][1] = 'Z'; road['Z'][0] = 'W'; road['Z'][1] = 'B'; road['B'][0] = 'Y'; road['B'][1] = 'X'; road['W'][0] = 'B'; road['W'][1] = 'Y'; road['Y'][0] = 'X'; while (cin >> str, str != "#") { char now_town = 'A'; bool flg = true; rep(i, str.length()) { int d = str[i] - '0'; now_town = road[now_town][d]; if (now_town == 0) { flg = false; break; } } if (now_town != 'B') { flg = false; } if (flg) { puts("Yes"); } else { puts("No"); } } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
307
4
#include <algorithm> #include <cstdio> #include <vector> using namespace std; int main() { int g[6][2] = {{1, 2}, {10, 3}, {1, 10}, {4, 5}, {5, 2}, {2, 1}}; char str[128]; while (scanf("%s", str), str[0] != '#') { int pos = 0; bool flag = false; for (int i = 0; str[i]; i++) { pos = g[pos][str[i] - '0']; if (pos == 10) { flag = true; break; } } if (flag) puts("NO"); else puts(pos == 5 ? "Yes" : "No"); } return 0; }
#include <algorithm> #include <cstdio> #include <vector> using namespace std; int main() { int g[6][2] = {{1, 2}, {10, 3}, {1, 10}, {4, 5}, {5, 2}, {2, 1}}; char str[128]; while (scanf("%s", str), str[0] != '#') { int pos = 0; bool flag = false; for (int i = 0; str[i]; i++) { pos = g[pos][str[i] - '0']; if (pos == 10) { flag = true; break; } } if (flag) puts("No"); else puts(pos == 5 ? "Yes" : "No"); } return 0; }
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
179
2
#include <iostream> #include <stdio.h> #include <string.h> using namespace std; int b[6][2] = {{1, 2}, {-1, 3}, {1, -1}, {4, 5}, {5, 2}, {1, 0}}; int main() { int i, j, a[1000], f = 0; char s[10000]; while (1) { scanf("%s\0", s); f = 0; if (s[0] == '#') break; int ans = 0; for (i = 0; i < strlen(s); i++) { if (s[i] == '0') { ans = b[ans][0]; if (ans == -1) { f = 1; break; } } else { ans = b[ans][1]; if (ans == -1) { f = 1; break; } } } if (f == 0 && ans == 5) { cout << "Yes" << endl; } else { cout << "No" << endl; } } return 0; }
#include <iostream> #include <stdio.h> #include <string.h> using namespace std; int b[6][2] = {{1, 2}, {-1, 3}, {1, -1}, {4, 5}, {5, 2}, {2, 1}}; int main() { int i, j, a[1000], f = 0; char s[10000]; while (1) { scanf("%s\0", s); f = 0; if (s[0] == '#') break; int ans = 0; for (i = 0; i < strlen(s); i++) { if (s[i] == '0') { ans = b[ans][0]; if (ans == -1) { // cout<<"tpo"<<endl; f = 1; break; } } else { ans = b[ans][1]; if (ans == -1) { // cout<<"tpo1"<<endl; f = 1; break; } } } if (f == 0 && ans == 5) { cout << "Yes" << endl; } else { cout << "No" << endl; } } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13]]
1
237
4
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; int main() { int a[][7] = {{2, 3, 6, 2, 5, 1, 6}, {3, 2, 4, 5, 1, 3, 6}}; for (;;) { string s; cin >> s; if (s == "#") return 0; int x = 0; for (unsigned i = 0; i < s.size(); ++i) x = a[s[i] - '0'][x]; if (x == 1) cout << "Yes" << endl; else cout << "No" << endl; } }
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; int main() { int a[][7] = {{2, 3, 6, 2, 5, 1, 6}, {3, 2, 4, 6, 1, 3, 6}}; for (;;) { string s; cin >> s; if (s == "#") return 0; int x = 0; for (unsigned i = 0; i < s.size(); ++i) x = a[s[i] - '0'][x]; if (x == 1) cout << "Yes" << endl; else cout << "No" << endl; } }
[["-", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13], ["+", 0, 43, 49, 50, 51, 83, 0, 83, 0, 13]]
1
176
2
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; inline int to_int(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string to_str(T x) { ostringstream sout; sout << x; return sout.str(); } typedef long long ll; typedef pair<int, int> P; pair<int, int> city[8]; void def(int n, int zero, int one) { city[n].first = zero; city[n].second = one; } int main() { // A:0 X:1 Y:2 Z:3 W:4 B:5 // // 0:first 1:second def(0, 1, 2); def(1, -1, 3); def(2, 1, -1); def(3, 4, 5); def(4, 5, 2); def(5, 2, 1); string a; while (cin >> a) { if (a == "#") { break; } int now = 0; for (int i = 0; i < a.size(); i++) { if (a[i] == '0') { now = city[now].first; } else if (a[i] == '1') { now = city[now].second; } if (now == -1) { break; } } cout << (now == 5 ? "YES" : "NO") << endl; } }
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; inline int to_int(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string to_str(T x) { ostringstream sout; sout << x; return sout.str(); } typedef long long ll; typedef pair<int, int> P; pair<int, int> city[8]; void def(int n, int zero, int one) { city[n].first = zero; city[n].second = one; } int main() { // A:0 X:1 Y:2 Z:3 W:4 B:5 // // 0:first 1:second def(0, 1, 2); def(1, -1, 3); def(2, 1, -1); def(3, 4, 5); def(4, 5, 2); def(5, 2, 1); string a; while (cin >> a) { if (a == "#") { break; } int now = 0; for (int i = 0; i < a.size(); i++) { if (a[i] == '0') { now = city[now].first; } else if (a[i] == '1') { now = city[now].second; } if (now == -1) { break; } } cout << (now == 5 ? "Yes" : "No") << endl; } }
[["-", 31, 16, 12, 23, 0, 41, 64, 5, 0, 6], ["+", 31, 16, 12, 23, 0, 41, 64, 5, 0, 6], ["-", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6], ["+", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6]]
1
334
4
#include <iostream> using namespace std; int d[10][10]; void init() { for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) d[i][j] = -1; d[0][0] = d[5][1] = d[2][0] = 1; d[0][1] = d[4][1] = d[5][0] = 2; d[1][1] = 3; d[3][0] = 4; d[3][1] = d[4][0] = 5; } string s; void solve() { int p = 0; for (int i = 0; i < (int)s.size(); i++) { int b = s[i] - '0'; p = d[p][b]; if (p == -1) break; } cout << (p == 5 ? "YES" : "NO") << endl; } int main() { init(); while (cin >> s && s != "#") { solve(); } }
#include <iostream> using namespace std; int d[10][10]; void init() { for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) d[i][j] = -1; d[0][0] = d[5][1] = d[2][0] = 1; d[0][1] = d[4][1] = d[5][0] = 2; d[1][1] = 3; d[3][0] = 4; d[3][1] = d[4][0] = 5; } string s; void solve() { int p = 0; for (int i = 0; i < (int)s.size(); i++) { int b = s[i] - '0'; p = d[p][b]; if (p == -1) break; } cout << (p == 5 ? "Yes" : "No") << endl; } int main() { init(); while (cin >> s && s != "#") { solve(); } }
[["-", 31, 16, 12, 23, 0, 41, 64, 5, 0, 6], ["+", 31, 16, 12, 23, 0, 41, 64, 5, 0, 6], ["-", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6], ["+", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6]]
1
262
4
#include <algorithm> #include <cstdio> #include <iostream> #include <string> using namespace std; int n; int v[11][2]; int main(void) { v[0][0] = 2; v[0][1] = 3; v[1][0] = 5; v[1][1] = 3; v[2][0] = -1; v[2][1] = 4; v[3][0] = 2; v[3][1] = -1; v[4][0] = 1; v[4][1] = 5; v[5][0] = 3; v[5][1] = 2; string s; while (cin >> s && s != "#") { n = 0; for (int i = 0; i < (int)s.size(); i++) { n = v[n][s[i] - '0']; if (n < 0) break; } if (n == 5) cout << "YES" << endl; else cout << "NO" << endl; } }
#include <algorithm> #include <cstdio> #include <iostream> #include <string> using namespace std; int n; int v[11][2]; int main(void) { v[0][0] = 2; v[0][1] = 3; v[1][0] = 5; v[1][1] = 3; v[2][0] = -1; v[2][1] = 4; v[3][0] = 2; v[3][1] = -1; v[4][0] = 1; v[4][1] = 5; v[5][0] = 3; v[5][1] = 2; string s; while (cin >> s && s != "#") { n = 0; for (int i = 0; i < (int)s.size(); i++) { n = v[n][s[i] - '0']; if (n < 0) break; } if (n == 5) cout << "Yes" << endl; else cout << "No" << endl; } }
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
243
4
#include <iostream> #include <string> using namespace std; int main() { int root[6][2] = {{1, 2}, {-1, 3}, {1, -1}, {4, 5}, {5, 2}, {2, 1}}; int now; string p; while (cin >> p) { if (p == "#") break; now = 0; for (int i = 0; i < p.size(); i++) { now = root[now][p[i] - '0']; if (now == -1) break; } if (now == 5) cout << "Yes" << endl; else cout << "NO" << endl; } }
#include <iostream> #include <string> using namespace std; int main() { int root[6][2] = {{1, 2}, {-1, 3}, {1, -1}, {4, 5}, {5, 2}, {2, 1}}; int now; string p; while (cin >> p) { if (p == "#") break; now = 0; for (int i = 0; i < p.size(); i++) { now = root[now][p[i] - '0']; if (now == -1) break; } if (now == 5) cout << "Yes" << endl; else cout << "No" << endl; } }
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
157
2
#include <iostream> main() { int i, n, m[7][2] = {4, 3, 3, 4, 0, 4, 6, 5, 3, 6, 2}; for (std::string p; std::cin >> p, n = p != "#"; std::cout << (n ? "No\n" : "Yes\n")) for (i = 0; i < p.size();) n = m[n][p[i++] - 48]; }
#include <iostream> main() { int i, n, m[7][2] = {4, 3, 3, 4, 0, 4, 6, 5, 3, 6, 2, 0, 6, 6}; for (std::string p; std::cin >> p, n = p != "#"; std::cout << (n ? "No\n" : "Yes\n")) for (i = 0; i < p.size();) n = m[n][p[i++] - 48]; }
[["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 21], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
1
114
6
#include <cstdio> #include <cstring> #include <iostream> #include <map> #include <string> using namespace std; int main() { string str; while (1) { int flg = 0; char NOW = 'A'; cin >> str; if (str == "#") break; for (int i = 0; i < str.size() && flg == 0; i++) { if (str[i] == '0') { if (NOW == 'A') NOW = 'X'; else if (NOW == 'X') flg = 1; else if (NOW == 'Z') NOW = 'W'; else if (NOW == 'B') NOW = 'Y'; else if (NOW == 'W') NOW = 'B'; else NOW = 'X'; } else { if (NOW == 'A') NOW = 'Y'; else if (NOW == 'X') NOW = 'Z'; else if (NOW == 'Z') NOW = 'B'; else if (NOW == 'B') NOW = 'X'; else if (NOW == 'W') NOW = 'Y'; else flg = 1; } } if (flg == 1 || NOW != 'B') cout << "NO" << endl; else cout << "YES" << endl; } }
#include <cstdio> #include <cstring> #include <iostream> #include <map> #include <string> using namespace std; int main() { string str; while (1) { int flg = 0; char NOW = 'A'; cin >> str; if (str == "#") break; for (int i = 0; i < str.size() && flg == 0; i++) { if (str[i] == '0') { if (NOW == 'A') NOW = 'X'; else if (NOW == 'X') flg = 1; else if (NOW == 'Z') NOW = 'W'; else if (NOW == 'B') NOW = 'Y'; else if (NOW == 'W') NOW = 'B'; else NOW = 'X'; } else { if (NOW == 'A') NOW = 'Y'; else if (NOW == 'X') NOW = 'Z'; else if (NOW == 'Z') NOW = 'B'; else if (NOW == 'B') NOW = 'X'; else if (NOW == 'W') NOW = 'Y'; else flg = 1; } } if (flg == 1 || NOW != 'B') cout << "No" << endl; else cout << "Yes" << endl; } }
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
282
4
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> using namespace std; #define F(i, n) for (int i = 0; i < (int)(n); i++) #define BW(x, a, b) (a <= x && x < b) #define SV(v, w) \ { \ F(i, v.size()) cout << setw(w) << v[i]; \ cout << endl; \ } int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, -1, 1}; int debug_counter = 0; #define debug_print printf("debug_print: %d\n", ++debug_counter) main() { string line; char dir, now; while (cin >> line && line != "#") { now = 'A'; F(i, line.size()) { dir = line.at(i); if (now == 'A') { if (dir == '0') { now = 'X'; } if (dir == '1') { now = 'Y'; } } else if (now == 'X') { if (dir == '0') { now = 'O'; } if (dir == '1') { now = 'Z'; } } else if (now == 'Y') { if (dir == '0') { now = 'X'; } if (dir == '1') { now = 'O'; } } else if (now == 'Z') { if (dir == '0') { now = 'W'; } if (dir == '1') { now = 'B'; } } else if (now == 'W') { if (dir == '0') { now = 'B'; } if (dir == '1') { now = 'Y'; } } else if (now == 'B') { if (dir == '0') { now = 'Y'; } if (dir == '1') { now = 'X'; } } else if (now == 'O') { if (dir == '0') { now = 'O'; } if (dir == '1') { now = 'O'; } } } if (now == 'B') { cout << "YES" << endl; } else { cout << "NO" << endl; } } }
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> using namespace std; #define F(i, n) for (int i = 0; i < (int)(n); i++) #define BW(x, a, b) (a <= x && x < b) #define SV(v, w) \ { \ F(i, v.size()) cout << setw(w) << v[i]; \ cout << endl; \ } int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, -1, 1}; int debug_counter = 0; #define debug_print printf("debug_print: %d\n", ++debug_counter) main() { string line; char dir, now; while (cin >> line && line != "#") { now = 'A'; F(i, line.size()) { dir = line.at(i); if (now == 'A') { if (dir == '0') { now = 'X'; } if (dir == '1') { now = 'Y'; } } else if (now == 'X') { if (dir == '0') { now = 'O'; } if (dir == '1') { now = 'Z'; } } else if (now == 'Y') { if (dir == '0') { now = 'X'; } if (dir == '1') { now = 'O'; } } else if (now == 'Z') { if (dir == '0') { now = 'W'; } if (dir == '1') { now = 'B'; } } else if (now == 'W') { if (dir == '0') { now = 'B'; } if (dir == '1') { now = 'Y'; } } else if (now == 'B') { if (dir == '0') { now = 'Y'; } if (dir == '1') { now = 'X'; } } else if (now == 'O') { if (dir == '0') { now = 'O'; } if (dir == '1') { now = 'O'; } } } if (now == 'B') { cout << "Yes" << endl; } else { cout << "No" << endl; } } }
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
470
4
$tb = { a: {0 => :x, 1 => :y}, x: {1 => :z}, y: {0 => :x}, z: {0 => :w, 1 => :b}, w: {0 => :b, 1 => :y}, b: {0 => :y, 1 => :x}, } def solve(routes) city = :a routes.each { |route| city = $tb[city][route] return false if city.nil? } city == :b end while (routes = gets.strip) != "#" puts solve(routes.chars.map(&:to_i)) ? "YES" : "NO" end
$tb = { a: {0 => :x, 1 => :y}, x: {1 => :z}, y: {0 => :x}, z: {0 => :w, 1 => :b}, w: {0 => :b, 1 => :y}, b: {0 => :y, 1 => :x}, } def solve(routes) city = :a routes.each { |route| city = $tb[city][route] return false if city.nil? } city == :b end while (routes = gets.strip) != "#" puts solve(routes.chars.map(&:to_i)) ? "Yes" : "No" end
[["-", 0, 652, 3, 4, 0, 754, 64, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 754, 64, 557, 0, 6], ["-", 0, 652, 3, 4, 0, 754, 75, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 754, 75, 557, 0, 6]]
4
137
4
dic={"A":{"0":"X","1":"Y"}, "X":{"0":"E","1":"Z"}, "Y":{"0":"X","1":"E"}, "Z":{"0":"W","1":"B"}, "W":{"0":"B","1":"Y"}, "B":{"0":"Y","1":"X"}, "E":{"0":"E","1":"E"}} while True: route=input() if route=="#":break state="A" for r in route: state=dic[state][r] print(state) print("YES" if state=="B" else "NO")
dic={"A":{"0":"X","1":"Y"}, "X":{"0":"E","1":"Z"}, "Y":{"0":"X","1":"E"}, "Z":{"0":"W","1":"B"}, "W":{"0":"B","1":"Y"}, "B":{"0":"Y","1":"X"}, "E":{"0":"E","1":"E"}} while True: route=input() if route=="#":break state="A" for r in route: state=dic[state][r] print("Yes" if state=="B" else "No")
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 52, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 652, 3, 4, 0, 41, 0, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 41, 0, 557, 0, 6]]
5
212
8
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n, n) { int num[2000] = {}, co = n; for (int i = 0; i < n; i++) cin >> num[i]; for (int i = 0;; i++) { bool kawa = 1; if (i == 10000) { cout << -1 << endl; break; } for (int j = co - 1; j > 0 && kawa; j--) if (num[j] != j + 1) kawa = 0; if (kawa) { cout << i << endl; break; } num[co] = co + 1; for (int j = 0; j <= co; j++) { if (num[j] == 1) { for (int k = j + 1; k <= co; k++) { if (num[k] != 1) { swap(num[j], num[k]); break; } } } num[j]--; } for (int j = co + 1; j >= 0; j--) { if (num[j] != 0) { co = j + 1; break; } } } } }
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n, n) { int num[2000] = {}, co = n; for (int i = 0; i < n; i++) cin >> num[i]; for (int i = 0;; i++) { bool kawa = 1; if (i == 10000) { cout << -1 << endl; break; } for (int j = co - 1; j >= 0 && kawa; j--) if (num[j] != j + 1) kawa = 0; if (kawa) { cout << i << endl; break; } num[co] = co + 1; for (int j = 0; j <= co; j++) { if (num[j] == 1) { for (int k = j + 1; k <= co; k++) { if (num[k] != 1) { swap(num[j], num[k]); break; } } } num[j]--; } for (int j = co + 1; j >= 0; j--) { if (num[j] != 0) { co = j + 1; break; } } } } }
[["-", 8, 9, 0, 7, 15, 16, 31, 16, 17, 47], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 17, 20]]
1
263
25
#include <algorithm> #include <cstdio> #include <vector> #define LIMIT 10000 using namespace std; bool ck(vector<int> &v) { for (int i = 0; i < v.size(); i++) if (v[i] != i + 1) return false; return true; } main() { int n, i, j, s, x, l; vector<int> tri; for (i = 1; i < 99; i++) tri.push_back(i * (i + 1) / 2); for (; scanf("%d", &n), n;) { vector<int> v; for (s = i = 0; i < n; i++) { scanf("%d", &x); s += x; v.push_back(x); } vector<int>::iterator idx = find(tri.begin(), tri.end(), s); i = LIMIT + 1; if (idx != tri.end()) { for (i = 0; i <= LIMIT && !ck(v); i++) { l = v.size(); for (j = 0; j < l; j++) v[j]--; v.erase(remove(v.begin(), v.end(), 0), v.end()); v.push_back(l); } } printf("%d\n", i > LIMIT ? -1 : i); } }
#include <algorithm> #include <cstdio> #include <vector> #define LIMIT 10000 using namespace std; bool ck(vector<int> &v) { for (int i = 0; i < v.size(); i++) if (v[i] != i + 1) return false; return true; } main() { int n, i, j, s, x, l; vector<int> tri; for (i = 1; i < 199; i++) tri.push_back(i * (i + 1) / 2); for (; scanf("%d", &n), n;) { vector<int> v; for (s = i = 0; i < n; i++) { scanf("%d", &x); s += x; v.push_back(x); } vector<int>::iterator idx = find(tri.begin(), tri.end(), s); i = LIMIT + 1; if (idx != tri.end()) { for (i = 0; i <= LIMIT && !ck(v); i++) { l = v.size(); for (j = 0; j < l; j++) v[j]--; v.erase(remove(v.begin(), v.end(), 0), v.end()); v.push_back(l); } } printf("%d\n", i > LIMIT ? -1 : i); } }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
316
2
#include <algorithm> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <vector> #define REP(i, m, n) for (int i = m; i < n; i++) #define rep(i, n) for (int i = 0; i < n; i++) #define rp(i, c) rep(i, (int)c.size()) #define fr(i, c) \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) #define mp make_pair #define pb push_back #define all(c) (c).begin(), (c).end() #define dbg(x) cerr << #x << " = " << (x) << endl using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; const int inf = 1 << 28; const double INF = 1e10, EPS = 1e-9; template <class T> int SIZE(T a) { return a.size(); } template <class T> string IntToString(T num) { string res; stringstream ss; ss << num; return ss.str(); } template <class T> T StringToInt(string str) { T res = 0; for (int i = 0; i < SIZE(str); i++) res = (res * 10 + str[i] - '0'); return res; } template <class T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } int main() { int n; while (cin >> n, n) { vector<int> list; rep(i, n) { int tmp; cin >> tmp; list.pb(tmp); } int count = 0; rep(i, 10000) { bool flag = true; rp(i2, list) { if (list[i2] != i2 + 1) { flag = false; break; } } if (flag) { break; } int s = list.size(); rp(i2, list) { list[i2]--; } list.erase(remove(list.begin(), list.end(), 0), list.end()); list.pb(s); count++; } if (count == 10000) { cout << count << endl; } else { cout << -1 << endl; } } }
#include <algorithm> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <vector> #define REP(i, m, n) for (int i = m; i < n; i++) #define rep(i, n) for (int i = 0; i < n; i++) #define rp(i, c) rep(i, (int)c.size()) #define fr(i, c) \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) #define mp make_pair #define pb push_back #define all(c) (c).begin(), (c).end() #define dbg(x) cerr << #x << " = " << (x) << endl using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; const int inf = 1 << 28; const double INF = 1e10, EPS = 1e-9; template <class T> int SIZE(T a) { return a.size(); } template <class T> string IntToString(T num) { string res; stringstream ss; ss << num; return ss.str(); } template <class T> T StringToInt(string str) { T res = 0; for (int i = 0; i < SIZE(str); i++) res = (res * 10 + str[i] - '0'); return res; } template <class T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } int main() { int n; while (cin >> n, n) { vector<int> list; rep(i, n) { int tmp; cin >> tmp; list.pb(tmp); } int count = 0; rep(i, 10000) { bool flag = true; rp(i2, list) { if (list[i2] != i2 + 1) { flag = false; break; } } if (flag) { break; } int s = list.size(); rp(i2, list) { list[i2]--; } list.erase(remove(list.begin(), list.end(), 0), list.end()); list.pb(s); count++; } if (!(count == 10000)) { cout << count << endl; } else { cout << -1 << endl; } } }
[["+", 8, 9, 0, 57, 15, 339, 51, 91, 17, 111], ["+", 0, 57, 15, 339, 51, 91, 28, 23, 0, 24], ["+", 0, 57, 15, 339, 51, 91, 28, 23, 0, 25]]
1
477
3
#include <stdio.h> int main() { int x, y; scanf("%d%d", &x, &y); printf("%d\n", x + y); }
#include <stdio.h> int main() { int x, y; scanf("%d%d", &x, &y); printf("%d\n", x * y); }
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 48]]
1
38
2
d,c = map(int,input(),split()) print(d * c)
d,c = map(int,input().split()) print(d * c)
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 0, 131]]
5
22
2
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int d = sc.nextInt(); int e = sc.nextInt(); int f = sc.nextInt(); if ((a * 1 + b * 5 + c * 10 + d * 50 + e * 100 + f * 500) / 1000 > 1) System.out.println(1); else System.out.println(0); } }
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int d = sc.nextInt(); int e = sc.nextInt(); int f = sc.nextInt(); if ((a * 1 + b * 5 + c * 10 + d * 50 + e * 100 + f * 500) / 1000 > 0) System.out.println(1); else System.out.println(0); } }
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499]]
3
139
2
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String str = reader.readLine(); int c1 = Integer.parseInt(str.split(" ", 0)[0]); int c2 = Integer.parseInt(str.split(" ", 0)[1]) * 5; int c3 = Integer.parseInt(str.split(" ", 0)[2]) * 10; int c4 = Integer.parseInt(str.split(" ", 0)[3]) * 50; int c5 = Integer.parseInt(str.split(" ", 0)[4]) * 100; int c6 = Integer.parseInt(str.split(" ", 0)[5]) * 500; int c = c1 + c2 + c3 + c4 + c5 + c6; if (c > 1000) System.out.println(1); else System.out.println(0); reader.close(); } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String str = reader.readLine(); int c1 = Integer.parseInt(str.split(" ", 0)[0]); int c2 = Integer.parseInt(str.split(" ", 0)[1]) * 5; int c3 = Integer.parseInt(str.split(" ", 0)[2]) * 10; int c4 = Integer.parseInt(str.split(" ", 0)[3]) * 50; int c5 = Integer.parseInt(str.split(" ", 0)[4]) * 100; int c6 = Integer.parseInt(str.split(" ", 0)[5]) * 500; int c = c1 + c2 + c3 + c4 + c5 + c6; if (c >= 1000) System.out.println(1); else System.out.println(0); reader.close(); } }
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 20]]
3
252
2
import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int a[] = new int[6]; a[1] = 1; a[2] = 5; a[3] = 10; a[4] = 50; a[5] = 100; a[6] = 500; int ans = 0; for (int i = 0; i < a.length; i++) { int temp = sc.nextInt(); ans += temp * a[i]; } if (ans >= 1000) System.out.println(1); else System.out.println(0); } }
import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int a[] = new int[6]; a[0] = 1; a[1] = 5; a[2] = 10; a[3] = 50; a[4] = 100; a[5] = 500; int ans = 0; for (int i = 0; i < a.length; i++) { int temp = sc.nextInt(); ans += temp * a[i]; } if (ans >= 1000) System.out.println(1); else System.out.println(0); } }
[["-", 8, 196, 0, 1, 0, 11, 31, 504, 71, 499], ["+", 8, 196, 0, 1, 0, 11, 31, 504, 71, 499]]
3
155
12
import java.util.*; class Main { int c1; int c5; int c10; int c50; int c100; int c500; int sum; Main() { Scanner sc = new Scanner(System.in); c1 = sc.nextInt(); c5 = sc.nextInt(); c10 = sc.nextInt(); c50 = sc.nextInt(); c100 = sc.nextInt(); c500 = sc.nextInt(); c1 = 1 * c1; c5 = 5 * c5; c10 = 10 * c10; c50 = 50 * c50; c100 = 100 * c100; c500 = 500 * c500; sum = c1 + c5 + c10 + c50 + c100 + c500; if (sum > 1000) { System.out.println("1"); } else { System.out.println("0"); } } public static void main(String[] args) { new Main(); } }
import java.util.*; class Main { int c1; int c5; int c10; int c50; int c100; int c500; int sum; Main() { Scanner sc = new Scanner(System.in); c1 = sc.nextInt(); c5 = sc.nextInt(); c10 = sc.nextInt(); c50 = sc.nextInt(); c100 = sc.nextInt(); c500 = sc.nextInt(); c1 = 1 * c1; c5 = 5 * c5; c10 = 10 * c10; c50 = 50 * c50; c100 = 100 * c100; c500 = 500 * c500; sum = c1 + c5 + c10 + c50 + c100 + c500; if (sum >= 1000) { System.out.println("1"); } else { System.out.println("0"); } } public static void main(String[] args) { new Main(); } }
[["-", 8, 519, 0, 57, 15, 15, 0, 16, 17, 47], ["+", 8, 519, 0, 57, 15, 15, 0, 16, 17, 20]]
3
196
2
import java.util.*; class Main { Main() { Scanner sc = new Scanner(System.in); int[] c = {1, 5, 10, 50, 100, 500}; int x = 0; for (int i = 0; i < 6; i++) { int a = sc.nextInt(); x = x + (c[i] * a); } int y = 0; if (x > 1000) y = 1; System.out.println(y); } public static void main(String[] arg) { new Main(); } }
import java.util.*; class Main { Main() { Scanner sc = new Scanner(System.in); int[] c = {1, 5, 10, 50, 100, 500}; int x = 0; for (int i = 0; i < 6; i++) { int a = sc.nextInt(); x = x + (c[i] * a); } int y = 0; if (x >= 1000) y = 1; System.out.println(y); } public static void main(String[] arg) { new Main(); } }
[["-", 8, 519, 0, 57, 15, 15, 0, 16, 17, 47], ["+", 8, 519, 0, 57, 15, 15, 0, 16, 17, 20]]
3
130
2
#include <stdio.h> int main() { int c1, c5, c10, c50, c100, c500, d, e, f, g, h, i, j; c1 = 1; c5 = 5; c10 = 10; c50 = 50; c100 = 100; c500 = 500; scanf("%d%d%d%d%d%d", &e, &f, &g, &h, &i, &j); d = (c1 * e) + (c5 * f) + (c10 * g) + (c50 * h) + (c100 * i) + (c500 * j); if (d >= 1000) { printf("1\n"); } if (1000 >= d) { printf("0\n"); } return 0; }
#include <stdio.h> int main() { int c1, c5, c10, c50, c100, c500, d, e, f, g, h, i, j; c1 = 1; c5 = 5; c10 = 10; c50 = 50; c100 = 100; c500 = 500; scanf("%d%d%d%d%d%d", &e, &f, &g, &h, &i, &j); d = (c1 * e) + (c5 * f) + (c10 * g) + (c50 * h) + (c100 * i) + (c500 * j); if (d >= 1000) { printf("1\n"); } if (1000 > d) { printf("0\n"); } return 0; }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47]]
0
157
2
#include <stdio.h> int main(void) { int a, b, c, d, e, f, x; scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f); x = a * 1 + b * 5 + c * 10 + d * 50 + e * 100 + f * 500; if (x > 1000) { printf("1\n"); } else { printf("0\n"); } return 0; }
#include <stdio.h> int main(void) { int a, b, c, d, e, f, x; scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f); x = a * 1 + b * 5 + c * 10 + d * 50 + e * 100 + f * 500; if (x >= 1000) { printf("1\n"); } else { printf("0\n"); } return 0; }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20]]
0
105
2
#include <stdio.h> int main() { int c1, c5, c10, c50, c100, c500, a, b, c, d, e, f; scanf("%d %d %d %d %d", &c1, &c5, &c10, &c50, &c100, &c500); a = c1; b = c5 * 5; c = c10 * 10; d = c50 * 50; e = c100 * 100; f = c500 * 500; if (a + b + c + d + e >= 1000) { printf("%d\n", 1); } else { printf("%d\n", 0); } return 0; }
#include <stdio.h> int main() { int c1, c5, c10, c50, c100, c500, a, b, c, d, e, f; scanf("%d %d %d %d %d %d", &c1, &c5, &c10, &c50, &c100, &c500); a = c1; b = c5 * 5; c = c10 * 10; d = c50 * 50; e = c100 * 100; f = c500 * 500; if (a + b + c + d + e + f >= 1000) { printf("%d\n", 1); } else { printf("%d\n", 0); } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 12, 22]]
0
134
4
#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); if (1000 < a * 1 + b * 5 + c * 10 + d * 50 + e * 100 + f * 500) { printf("1\n"); } else { printf("0\n"); } return 0; }
#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); if (1000 <= a * 1 + b * 5 + c * 10 + d * 50 + e * 100 + f * 500) { printf("1\n"); } else { printf("0\n"); } return 0; }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 19]]
0
99
2
#include <stdio.h> int main(void) { int c1, c5, c10, c50, c100, c500, a; scanf("%d %d %d %d %d %d", &c1, &c5, &c10, &c50, &c100, &c500); a = c1 + 5 * c5 * 10 * c10 + 50 * c50 + 100 * c100 + 500 * c500; if (a >= 1000) printf("1\n"); else printf("0\n"); return 0; }
#include <stdio.h> int main(void) { int c1, c5, c10, c50, c100, c500, a; scanf("%d %d %d %d %d %d", &c1, &c5, &c10, &c50, &c100, &c500); a = c1 + 5 * c5 + 10 * c10 + 50 * c50 + 100 * c100 + 500 * c500; if (a >= 1000) printf("1\n"); else printf("0\n"); return 0; }
[["-", 31, 16, 31, 16, 12, 16, 31, 16, 17, 48], ["+", 12, 16, 31, 16, 31, 16, 31, 16, 17, 72]]
0
99
2
#include <stdio.h> int main(void) { int i; int n, sum = 0; int money[6] = {1, 5, 10, 50, 100, 500}; for (i = 0; i < 6; i++) { scanf("%d", &n); money[i] *= n; sum += money[i]; } printf("%d\n", (sum > 1000)); return 0; }
#include <stdio.h> int main(void) { int i; int n, sum = 0; int money[6] = {1, 5, 10, 50, 100, 500}; for (i = 0; i < 6; i++) { scanf("%d", &n); money[i] *= n; sum += money[i]; } printf("%d\n", (sum >= 1000)); return 0; }
[["-", 0, 2, 3, 4, 0, 23, 0, 16, 17, 47], ["+", 0, 2, 3, 4, 0, 23, 0, 16, 17, 20]]
0
95
2