buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
#include <math.h> #include <stdio.h> int main(void) { int q; double x; while (1) { scanf("%d", &q); if (q == -1) break; x = q / 2; while (fabs(pow(x, 3) - q) >= 0.00001 * q) x = x - (pow(x, 3) - q) / (3.0 * pow(x, 2)); printf("%lf\n", x); } return 0; }
#include <math.h> #include <stdio.h> int main(void) { int q; double x; while (1) { scanf("%d", &q); if (q == -1) break; x = q / 2.0; while (fabs(pow(x, 3) - q) >= 0.00001 * q) x = x - (pow(x, 3) - q) / (3.0 * pow(x, 2)); printf("%lf\n", x); } return 0; }
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
0
104
2
#include <math.h> #include <stdio.h> int main() { double q, x; while (scanf("%lf", &q) != EOF) { if (q == -1) break; x = q / 2; while ((pow(x, 3) - q) >= 0.00001 * q) { x = x - (pow(x, 3) - q) / (3.0 * pow(x, 2)); } printf("%0.6lf\n", x); } return 0; }
#include <math.h> #include <stdio.h> int main() { double q, x; while (scanf("%lf", &q) != EOF) { if (q == -1) break; x = q / 2; while (fabs(pow(x, 3) - q) >= 0.00001 * q) { x = x - (pow(x, 3) - q) / (3.0 * pow(x, 2)); } printf("%0.6lf\n", x); } return 0; }
[["+", 0, 52, 15, 23, 0, 16, 31, 2, 63, 22]]
0
103
1
#include <stdio.h> int main(int argc, char const *argv[]) { int q; while (scanf("%d", &q), ~q) { double x = q / 2.; while (x * x * x - q >= 0.00001 * q) { x = x - ((x * x * x - q) / (3 * x * x)); } printf("%.6f\n", x); } return (0); }
#include <stdio.h> int main(int argc, char const *argv[]) { int q; while (scanf("%d", &q), ~q) { double x = q / 2.; while (fabs(x * x * x - q) >= 0.00001 * q) { x = x - ((x * x * x - q) / (3 * x * x)); } printf("%.6f\n", x); } return (0); }
[["+", 0, 52, 15, 23, 0, 16, 31, 2, 63, 22], ["+", 15, 23, 0, 16, 31, 2, 3, 4, 0, 24], ["+", 15, 23, 0, 16, 31, 2, 3, 4, 0, 25]]
0
99
3
#include <stdio.h> int main(void) { int q; double x; while (1) { scanf("%d", &q); if (q == -1) break; x = q / 2; while (x * x * x - q <= -0.00001 * q || 0.00001 * q <= x * x * x - q) { x -= (x * x * x - q) / (3 * x * x); } printf("%lf\n", x); } return 0; }
#include <stdio.h> int main(void) { int q; double x; while (1) { scanf("%d", &q); if (q == -1) break; x = q / 2.0; while (x * x * x - q <= -0.00001 * q || 0.00001 * q <= x * x * x - q) { x = x - (x * x * x - q) / (3 * x * x); } printf("%lf\n", x); } return 0; }
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 110], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33]]
0
106
6
#include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int q; while (cin >> q, q != -1) { double x = q / 2.0; double eps = 0.0001 * q; while (eps <= abs(x * x * x - q)) { x = x - (x * x * x - q) / (3 * x * x); } cout.precision(6); co...
#include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int q; while (cin >> q, q != -1) { double x = q / 2.0; double eps = 0.00001 * q; while (eps <= abs(x * x * x - q)) { x = x - (x * x * x - q) / (3 * x * x); } cout.precision(6); c...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 13]]
1
104
2
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; double abso(double n) { if ...
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; double abso(double n) { if ...
[["+", 0, 1, 0, 11, 12, 16, 31, 74, 0, 24], ["+", 0, 11, 12, 16, 31, 74, 39, 77, 39, 40], ["+", 0, 1, 0, 11, 12, 16, 31, 74, 0, 25], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
142
5
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pair<int, int>> vii; #define rrep(i, m, n) for (int(i) = (m); (i) < (n); (i)++) #define erep(i, m, n) for (int(i) = (m); (i) <= (n); (i)++) #define rep(i, n) for (int(i) = 0; (i) <...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pair<int, int>> vii; #define rrep(i, m, n) for (int(i) = (m); (i) < (n); (i)++) #define erep(i, m, n) for (int(i) = (m); (i) <= (n); (i)++) #define rep(i, n) for (int(i) = 0; (i) <...
[["-", 15, 339, 51, 91, 28, 2, 3, 4, 0, 21], ["-", 51, 91, 28, 2, 3, 4, 0, 2, 63, 22], ["-", 28, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 28, 2, 3, 4, 0, 16, 31, 16, 17, 48], ["+", 51, 91, 28, 2, 3, 4, 0, 16, 17, 48], ["+", 51, 91, 28, 2, 3, 4, 0, 16, 12, 22], ["-", 28, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
452
7
#include <cmath> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; int main() { long long int q; double x; while (cin >> q) { if (q != -1) { x = q / 2; while (abs(pow(x, 3) - q) >= 0.00001 * q) { x = x - ((pow(x, 3) - q) / (3 * pow(x, 2))); ...
#include <cmath> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; int main() { long long int q; double x; while (cin >> q) { if (q != -1) { x = (double)q / 2; while (abs(pow(x, 3) - q) >= 0.00001 * q) { x = x - ((pow(x, 3) - q) / (3 * pow(x,...
[["+", 0, 1, 0, 11, 12, 16, 31, 74, 0, 24], ["+", 0, 11, 12, 16, 31, 74, 39, 77, 39, 40], ["+", 0, 1, 0, 11, 12, 16, 31, 74, 0, 25]]
1
111
3
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; // < "D:\D_Download\Visual Studio // 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D...
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; // < "D:\D_Download\Visual Studio // 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D...
[["-", 0, 52, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 52, 8, 9, 0, 43, 39, 86, 39, 40], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 78]]
1
5,380
4
#include <cmath> #include <cstdio> using namespace std; double q; int main() { while (1) { scanf("%lf", &q); if (q == -1.0) return 0; double ans = q / 2; while (abs(ans * ans * ans - q) >= 10e-5 * q) { ans = ans - (ans * ans * ans - q) / (3 * ans * ans); } printf("%f\n", ans); ...
#include <cmath> #include <cstdio> using namespace std; double q; int main() { while (1) { scanf("%lf", &q); if (q == -1.0) return 0; double ans = q / 2; while (abs(ans * ans * ans - q) >= 1e-5 * q) { ans = ans - (ans * ans * ans - q) / (3 * ans * ans); } printf("%f\n", ans); ...
[["-", 0, 52, 15, 339, 51, 16, 12, 16, 31, 13], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 31, 13]]
1
100
2
#include <bits/stdc++.h> using namespace std; // typedef unsigned double d; double temp(double, double); double temp(double x, double q) { x -= (x * x * x - q) / (3 * x * x); return x; } int main() { double x[50], q; int i; for (i = 0; i < 50; i++) { cin >> q; if (q == -1) break; x[i] = q ...
#include <bits/stdc++.h> using namespace std; double temp(double, double); double temp(double x, double q) { x -= (x * x * x - q) / (3 * x * x); return x; } int main() { double x[50], q; int i; for (i = 0; i < 50; i++) { cin >> q; if (q == -1) break; x[i] = q / 2; do { x[i] = tem...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
176
2
#include <cmath> #include <cstdio> #include <iostream> using namespace std; typedef long long LL; typedef long double LD; int main() { LL q; LD x; while (1) { cin >> q; if (q == -1) break; x = (LD)q / 2.0; while (abs(x * x * x - q) >= 0.00001 * q) { x = x - (x * x * x - q) / (3....
#include <cmath> #include <cstdio> #include <iostream> using namespace std; typedef int LL; typedef double LD; int main() { LL q; LD x; while (1) { cin >> q; if (q == -1) break; x = (LD)q / 2.0; while (abs(x * x * x - q) >= 0.00001 * q) { x = x - (x * x * x - q) / (3.0 * x * x);...
[["-", 36, 36, 0, 30, 0, 134, 39, 86, 0, 96], ["+", 36, 36, 36, 36, 0, 30, 0, 134, 39, 40]]
1
110
4
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; int main() { long long int in; while (cin >> in, in + 1) { long double x = in / 2; while (x * x * x - in > 0.000000001 * in || x * x * x - in < -0.000000001 * in) ...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; int main() { long long int in; while (cin >> in, in + 1) { double x = in / 2; while (x * x * x - in > 0.00001 * in || x * x * x - in < -0.00001 * in) x -= (x * x * x - i...
[["-", 0, 52, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 31, 13], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 31, 13], ["-", 15, 339, 51, 16, 12, 16, 12, 16, 31, 13], ["+", 15, 339, 51, 16, 12, 16, 12, 16, 31, 13], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
116
7
while true q=gets.to_f break if(q==-1) x=q/2 p x while (x**3-q).abs>=0.00001 x=x-((x**3-q)/(3*x*x)) end printf("%.6f\n", x) end
while true q=gets.to_f break if(q==-1) x=q/2 while (x**3-q).abs>0.00001*q x=x-((x**3-q)/(3*x*x)) end printf("%.6f\n", x) end
[["-", 0, 493, 0, 89, 8, 170, 0, 652, 735, 22], ["-", 0, 89, 8, 170, 0, 652, 3, 4, 0, 22], ["-", 0, 89, 8, 170, 0, 89, 15, 738, 17, 20], ["+", 0, 89, 8, 170, 0, 89, 15, 738, 17, 47], ["+", 8, 170, 0, 89, 15, 738, 12, 738, 17, 48], ["+", 8, 170, 0, 89, 15, 738, 12, 738, 12, 22]]
4
66
6
readlines.map(&:to_f).each{|q| break if q == -1 x = q / 2.0 loop do break if (x * x * x - q).abs < 0.0001 * q x -= (x * x * x - q)/(3.0*x * x) end puts "%.8f" % x }
readlines.map(&:to_f).each{|q| break if q == -1 x = q / 2.0 loop do break if (x * x * x - q).abs < 0.00001 * q x -= (x * x * x - q)/(3.0*x * x) end puts "%.8f" % x }
[["-", 8, 736, 0, 751, 15, 738, 12, 738, 31, 531], ["+", 8, 736, 0, 751, 15, 738, 12, 738, 31, 531]]
4
70
2
loop do q = gets.to_f break if q < 0 x = q / 2 x = x - (x**3 - q) / (3 * x**2) until x**3 - q < 0.00001 * q p x end
loop do q = gets.to_f break if q < 0 x = q / 2 x = x - (x**3 - q) / (3 * x**2) until (x**3 - q).abs < 0.00001 * q p x end
[["+", 0, 770, 15, 738, 31, 652, 486, 739, 0, 24], ["+", 0, 770, 15, 738, 31, 652, 486, 739, 0, 25], ["+", 8, 736, 0, 770, 15, 738, 31, 652, 17, 131], ["+", 8, 736, 0, 770, 15, 738, 31, 652, 735, 22]]
4
49
4
def third_root(q): x=q/2.0 while abs(x**3-q)>=q*10**(-5): x=x-(x**3-q)/(3*x**2) return x while 1: q=input() if q==-1:break ans=third_root(q) print(ans)
def third_root(q): x=q/2.0 while abs(x**3-q)>=q*10**(-5): x=x-(x**3-q)/(3*x**2) return x while True: q=int(input()) if q==-1:break ans=third_root(q) print(ans)
[["-", 36, 36, 36, 36, 0, 656, 0, 52, 15, 612], ["+", 36, 36, 36, 36, 0, 656, 0, 52, 15, 146], ["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
76
5
def third_root(q): x=q/2 while abs(x**3-q)>=q*10**(-5): x=x-(x**3-q)/(3*x**2) return x while 1: q=input() if q==-1:break ans=third_root(q) print(ans)
def third_root(q): x=q/2 while abs(x**3-q)>=q*10**(-5): x=x-(x**3-q)/(3*x**2) return x while 1: q=eval(input()) if q==-1:break ans=third_root(q) print(ans)
[["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
76
3
import math while True: q = int(input()) if q == -1: break x = float(q)/2 while abs(x**3-q) >= 0.0001*q: x = x - (x**3 - q)/(3*x**2) print(x)
import math while True: q = int(input()) if q == -1: break x = float(q)/2 while abs(x**3 - q) >= 0.00001*q: x = x - (x**3 - q)/(3*x**2) print(x)
[["-", 8, 196, 0, 52, 15, 666, 0, 657, 31, 531], ["+", 8, 196, 0, 52, 15, 666, 0, 657, 31, 531]]
5
65
8
import math while True: q = int(input()) if q == -1: break x = float(q)/2 while abs(x**3-q) >= 0.0001*q: x = x - (x**3 - q)/(3*x**2) print(x)
while True: q = int(input()) if q == -1: break x = float(q)/2 while abs(x**3 - q) >= 0.00001*q: x = x - (x**3 - q)/(3*x**2) print(x)
[["-", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["-", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 8, 196, 0, 52, 15, 666, 0, 657, 31, 531], ["+", 8, 196, 0, 52, 15, 666, 0, 657, 31, 531]]
5
65
8
import math while True: q = int(input()) if q == -1: break x = float(q)/2 while abs(x**3-q) >= 0.0001*q: x = x - (x**3 - q)/(3*x**2) print(x)
while True: q = int(input()) if q == -1: break x = float(q)/2 while abs(x**3 - q) >= 0.00001*q: x -= (x**3 - q)/(3*x**2) print(x)
[["-", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["-", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 8, 196, 0, 52, 15, 666, 0, 657, 31, 531], ["+", 8, 196, 0, 52, 15, 666, 0, 657, 31, 531], ["-", 0, 52, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 52, 8, 196, 0, 1, 0, 662, 0, 32], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, ...
5
65
8
#include <iostream> using namespace std; int main() { int jenny[] = {1, 2, 1, 2, 1, 4, 1, 4, 1, 2, 1, 2, 1, 4, 1, 4}; int ans[8]; int customer[8]; while (true) { int best = 60000; for (int i = 0; i < 8; i++) { cin >> customer[i]; if (cin.eof()) { return 0; } } fo...
#include <iostream> using namespace std; int main() { int jenny[] = {1, 2, 1, 2, 1, 4, 1, 4, 1, 2, 1, 2, 1, 4, 1, 4}; int ans[8]; int customer[8]; while (true) { int best = 60000; for (int i = 0; i < 8; i++) { cin >> customer[i]; if (cin.eof()) { return 0; } } fo...
[["-", 64, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 64, 9, 0, 57, 64, 9, 0, 116, 0, 117]]
1
340
2
#include <algorithm> #include <cstdio> using namespace std; int p[8], t[8], u[8], c[8] = {1, 4, 1, 4, 1, 2, 1, 2}; bool comp() { for (int j = 0; j < 8; j++) { if (t[j] > u[j]) return true; if (t[j] < u[j]) return false; } return false; } int main() { while (~scanf("%d%d%d%d%d%d%d%d", &p[0], ...
#include <algorithm> #include <cstdio> using namespace std; int p[8], t[8], u[8], c[8] = {1, 4, 1, 4, 1, 2, 1, 2}; bool comp() { for (int j = 0; j < 8; j++) { if (t[j] > u[j]) return true; if (t[j] < u[j]) return false; } return false; } int main() { while (~scanf("%d%d%d%d%d%d%d%d", &p[0], ...
[["-", 0, 52, 8, 9, 0, 7, 8, 9, 0, 45], ["-", 0, 2, 3, 4, 0, 41, 64, 5, 0, 6], ["+", 0, 2, 3, 4, 0, 41, 64, 5, 0, 6], ["-", 0, 52, 8, 9, 0, 7, 8, 9, 0, 46]]
1
383
4
#include <algorithm> #include <cstdio> #include <utility> using namespace std; typedef pair<int, int> Pair; #define INF 0x7fffffff int d[] = {4, 1, 4, 1, 2, 1, 2, 1}; int ps[100]; int main() { while (1) { for (int i = 0; i < 8; i++) { if (scanf("%d", &ps[i]) != 1) return 0; } int mod = 1...
/* fuck */ #include <algorithm> #include <cstdio> #include <utility> using namespace std; typedef pair<int, int> Pair; #define INF 0x7fffffff int d[] = {4, 1, 4, 1, 2, 1, 2, 1}; int ps[100]; int main() { while (1) { for (int i = 0; i < 8; i++) { if (scanf("%d", &ps[i]) != 1) return 0; } ...
[["+", 0, 52, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
273
6
#include <iomanip> #include <iostream> #include <limits.h> using namespace std; int max(int x, int y) { return x > y ? x : y; } int main() { int capacity[8] = {4, 1, 4, 1, 2, 1, 2, 1}; int index[8] = {3, 5, 7, 1, 4, 6, 2, 0}; int p[8]; while (cin >> p[0]) { for (int i = 1; i < 8; i++) cin >> p[i];...
#include <iomanip> #include <iostream> #include <limits.h> using namespace std; int max(int x, int y) { return x > y ? x : y; } int main() { int capacity[8] = {4, 1, 4, 1, 2, 1, 2, 1}; int index[8] = {3, 5, 1, 7, 4, 6, 2, 0}; int p[8]; while (cin >> p[0]) { for (int i = 1; i < 8; i++) cin >> p[i];...
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 21], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 21], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
1
267
4
#include <climits> #include <iostream> using namespace std; #define N 8 int main() { int vehicle[N] = {4, 1, 4, 1, 2, 1, 2, 1}, passenger[N]; int i, j, wait, min, place; while (cin >> passenger[0]) { for (i = 1; i < N; i++) cin >> passenger[i]; min = INT_MAX; place = 0; for (i = 0; i < N;...
#include <climits> #include <iostream> using namespace std; #define N 8 int main() { int vehicle[N] = {4, 1, 4, 1, 2, 1, 2, 1}, passenger[N]; int i, j, wait, min, place; while (cin >> passenger[0]) { for (i = 1; i < N; i++) cin >> passenger[i]; min = INT_MAX; place = 0; for (i = 0; i < N;...
[["+", 0, 1, 0, 11, 12, 16, 12, 16, 17, 48], ["+", 0, 1, 0, 11, 12, 16, 12, 16, 12, 22]]
1
303
2
#include <algorithm> #include <iostream> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define ll long long #define INF 2147483647 int main() { int w[8], c[8] = {1, 2, 1, 2, 1, 4, 1, 4}, dict[8] = {0, 2, 6, 4, 1, 3, 7, 5}; while (1) { int r[8] = {0}, m = INF; rep(i, 8) if (!(cin >> w[...
#include <algorithm> #include <iostream> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define ll long long #define INF 2147483647 int main() { int w[8], c[8] = {1, 2, 1, 2, 1, 4, 1, 4}, dict[8] = {0, 2, 6, 4, 1, 3, 7, 5}; while (1) { int r[8] = {0}, m = INF; rep(i, 8) if (!(cin >> w[...
[["-", 3, 4, 0, 69, 341, 342, 0, 16, 17, 33], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 17, 72]]
1
261
2
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; const double EPS = 1e-9; const double PI = 3....
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; const double EPS = 1e-9; const double PI = 3....
[["-", 0, 7, 8, 9, 0, 1, 0, 11, 12, 146], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 147]]
1
335
2
#include <algorithm> #include <climits> #include <cstdio> using namespace std; int main() { int i, j, k, s, t, u; int l[8]; int m[8] = {4, 1, 4, 1, 2, 1, 2, 1}; int o[8] = {0, 2, 6, 4, 3, 5, 1, 7}; while (1) { for (i = 0; i < 8; i++) { s = scanf("%d", &l[i]); } if (s != 1) break; ...
#include <algorithm> #include <climits> #include <cstdio> using namespace std; int main() { int i, j, k, s, t, u; int l[8]; int m[8] = {4, 1, 4, 1, 2, 1, 2, 1}; int o[8] = {0, 2, 6, 4, 7, 1, 5, 3}; while (1) { for (i = 0; i < 8; i++) { s = scanf("%d", &l[i]); } if (s != 1) break; ...
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 21], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 21]]
1
282
8
#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 <ve...
#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 <ve...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 2, 3, 4, 0, 41, 75, 5, 0, 44]]
1
518
5
#include <algorithm> #include <iostream> using namespace std; int main() { int k[8]; string mery = "41212141", ans; while (cin >> k[0] >> k[1] >> k[2] >> k[3] >> k[4] >> k[5] >> k[6] >> k[7]) { int mn = 5 << 30, mnum = 5 << 30; for (int i = 0; i < 8; i++) { rotate(mery.begin(), mery.begin() + 1, m...
#include <algorithm> #include <iostream> using namespace std; int main() { int k[8]; string mery = "41212141", ans; while (cin >> k[0] >> k[1] >> k[2] >> k[3] >> k[4] >> k[5] >> k[6] >> k[7]) { int mn = 5 << 30, mnum = 5 << 30; for (int i = 0; i < 8; i++) { rotate(mery.begin(), mery.begin() + 1, m...
[["+", 64, 9, 0, 57, 75, 76, 0, 57, 0, 121], ["+", 0, 57, 75, 76, 0, 57, 15, 339, 0, 24], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 0, 57, 75, 76, 0, 57, 15, 339, 0, 25]]
1
300
6
#include <iostream> using namespace std; int check(int p[], int data[]) { int cnt = 0; for (int i = 0; i < 8; i++) cnt += max(0, data[i] - p[i]); return cnt; } int makeint(int p[]) { int ans = 0; for (int i = 0; i < 8; i++) { ans *= 10; ans += p[i]; } return ans; } int main() { int p[8];...
#include <iostream> using namespace std; int check(int p[], int data[]) { int cnt = 0; for (int i = 0; i < 8; i++) cnt += max(0, data[i] - p[i]); return cnt; } int makeint(int p[]) { int ans = 0; for (int i = 0; i < 8; i++) { ans *= 10; ans += p[i]; } return ans; } int main() { int p[8];...
[["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22]]
1
401
4
#include <iostream> using namespace std; int main() { int pdata[8]; int cdata[8][8] = { {4, 1, 4, 1, 2, 1, 2, 1}, {4, 1, 2, 1, 2, 1, 4, 1}, {2, 1, 4, 1, 4, 1, 2, 1}, {2, 1, 2, 1, 4, 1, 4, 1}, {1, 4, 1, 4, 1, 2, 1, 2}, {1, 4, 1, 2, 1, 2, 1, 4}, {1, 2, 1, 4, 1, 4, 1, 2}, {1, 2, 1, 2, 1, 4, ...
#include <iostream> using namespace std; int main() { int pdata[8]; int cdata[8][8] = { {4, 1, 4, 1, 2, 1, 2, 1}, {4, 1, 2, 1, 2, 1, 4, 1}, {2, 1, 4, 1, 4, 1, 2, 1}, {2, 1, 2, 1, 4, 1, 4, 1}, {1, 4, 1, 4, 1, 2, 1, 2}, {1, 4, 1, 2, 1, 2, 1, 4}, {1, 2, 1, 4, 1, 4, 1, 2}, {1, 2, 1, 2, 1, 4, ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]]
1
359
2
#include <cstdlib> #include <iostream> #include <string> std::string B = "4141212141412121"; int main() { int i, j, C[8] = {}, x[8] = {}, s, m, p, tmp; for (i = 7; i--;) C[i] = atoi(B.substr(i, 8).c_str()); while (std::cin >> x[0]) { m = x[0]; for (i = 1; i < 8; i++) { std::cin >> x[i]; m ...
#include <cstdlib> #include <iostream> #include <string> std::string B = "4141212141412121"; int main() { int i, j, C[8] = {}, x[8] = {}, s, m, p, tmp; for (i = 8; i--;) C[i] = atoi(B.substr(i, 8).c_str()); while (std::cin >> x[0]) { m = x[0]; for (i = 1; i < 8; i++) { std::cin >> x[i]; m ...
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 10, 11, 12, 13]]
1
261
6
#!/usr/bin/ruby # coding: utf-8 PI = Math.acos(-1) EPS = 0.00001 it = [4,1,4,1,2,1,2,1] def dif(xs, ys) r = 0 for i in 0...xs.length r += [xs[i], ys[i]].min end r end def less(xs, ys) for i in 0...xs.length if xs[i] < ys[i] return true elsif xs[i] > ys[i] return false end end...
#!/usr/bin/ruby # coding: utf-8 PI = Math.acos(-1) EPS = 0.00001 it = [4,1,4,1,2,1,2,1] def dif(xs, ys) r = 0 for i in 0...xs.length r += [xs[i], ys[i]].min end r end def less(xs, ys) for i in 0...xs.length if xs[i] < ys[i] return true elsif xs[i] > ys[i] return false end end...
[["-", 0, 738, 12, 739, 0, 652, 3, 4, 0, 22], ["-", 0, 738, 12, 739, 0, 652, 3, 4, 0, 21], ["+", 0, 738, 12, 739, 0, 652, 3, 4, 0, 21], ["+", 0, 738, 12, 739, 0, 652, 3, 4, 0, 22]]
4
206
4
c = [4,1,4,1,2,1,2,1] readlines.each do |l| p = l.split.map(&:to_i) ans = 7.times.map{ c=c.rotate }.sort do |a,b| t = (a.zip(p).map{|i,j| [i-j,0].max}.inject(:+) <=> b.zip(p).map{|i,j| [i-j,0].max}.inject(:+)) t==0 ? a.join.to_i <=> b.join.to_i : t end.first puts ans.join(" ") end
c = [4,1,4,1,2,1,2,1] readlines.each do |l| p = l.split.map(&:to_i) ans = 8.times.map{ c=c.rotate }.sort do |a,b| t = (a.zip(p).map{|i,j| [i-j,0].max}.inject(:+) <=> b.zip(p).map{|i,j| [i-j,0].max}.inject(:+)) t==0 ? a.join.to_i <=> b.join.to_i : t end.first puts ans.join(" ") end
[["-", 12, 652, 486, 652, 486, 652, 486, 652, 486, 612], ["+", 12, 652, 486, 652, 486, 652, 486, 652, 486, 612]]
4
152
2
def comp(lst1, lst2): for v1, v2 in zip(lst1, lst2): if v1 < v2: return False if v1 > v2: return True return False while True: try: plst = list(map(int, input().split())) horse = [4, 1, 4, 1, 2, 1, 2, 1] min_num = 100000 min_horse = horse[:] for _ in range(8): ...
def comp(lst1, lst2): for v1, v2 in zip(lst1, lst2): if v1 < v2: return False if v1 > v2: return True return False while True: try: plst = list(map(int, input().split())) horse = [4, 1, 4, 1, 2, 1, 2, 1] min_num = 100000 min_horse = horse[:] for _ in range(8): ...
[["+", 8, 196, 0, 57, 15, 679, 12, 652, 63, 22], ["+", 0, 57, 15, 679, 12, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 57, 15, 679, 12, 666, 667, 47], ["+", 0, 57, 15, 679, 12, 652, 3, 4, 0, 21], ["+", 0, 57, 15, 679, 12, 652, 3, 4, 0, 25], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22...
5
186
7
while True: try: plst = list(map(int, input().split())) horse = [4, 1, 4, 1, 2, 1, 2, 1] max_num = -1 max_horse = horse[:] for i in range(8): #乗車可能人数 num = sum([min(horse[j], plst[j]) for j in range(8)]) #人数が最大値と等しく、並びの数値が小さければ更新 if num == max_num and max_h...
while True: try: plst = list(map(int, input().split())) horse = [4, 1, 4, 1, 2, 1, 2, 1] max_num = -1 max_horse = horse[:] for _ in range(8): #乗車可能人数 num = sum([min(plst[j], horse[j]) for j in range(8)]) #人数が最大値と等しく、並びの数値が小さければ更新 if num == max_num and max_h...
[["-", 8, 196, 0, 246, 8, 196, 0, 7, 31, 22], ["+", 8, 196, 0, 246, 8, 196, 0, 7, 31, 22], ["-", 0, 658, 8, 652, 3, 4, 0, 206, 51, 22], ["+", 0, 658, 8, 652, 3, 4, 0, 206, 51, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22]]
5
149
8
c = [4,1,4,1,2,1,2,1] while True: try: que = list(map(int, input().split())) mx,mxc = 0, "99999999" for sp in range(8): sm = 0 for num in range(8): sm += c[(sp+num)%8] if c[(sp+num)%8] <= que[num] else que[num] if sm > mx: mx = sm mxc = "".join(map(str, c[sp:]+c[:sp])) elif sm == mx: ...
c = [4,1,4,1,2,1,2,1] while True: try: que = list(map(int, input().split())) mx,mxc = 0, "99999999" for sp in range(8): sm = 0 for num in range(8): sm += c[(sp+num)%8] if c[(sp+num)%8] <= que[num] else que[num] if sm > mx: mx = sm mxc = "".join(map(str, c[sp:]+c[:sp])) elif sm == mx: ...
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
5
196
2
import java.util.Calendar; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int year = scanner.nextInt(); int month = scanner.nextInt(); int date = scanner.nextInt(); Calend...
import java.util.Calendar; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int year = scanner.nextInt(); int month = scanner.nextInt(); int date = scanner.nextInt(); Calend...
[["-", 3, 4, 0, 492, 3, 4, 0, 5, 0, 491], ["+", 3, 4, 0, 492, 3, 4, 0, 5, 0, 491]]
3
382
2
import static java.lang.Math.abs; import static java.lang.Math.atan2; import static java.lang.Math.sqrt; import static java.util.Arrays.deepToString; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void tr(Object... os) { System....
import static java.lang.Math.abs; import static java.lang.Math.atan2; import static java.lang.Math.sqrt; import static java.util.Arrays.deepToString; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void tr(Object... os) { System....
[["-", 15, 15, 0, 16, 31, 16, 31, 16, 12, 499], ["+", 15, 15, 0, 16, 31, 16, 31, 16, 12, 499]]
3
551
2
import java.util.Scanner; public class Main { static int meiji = era(1868, 9, 8), taisho = era(1912, 7, 30), showa = era(1926, 12, 25), heisei = era(1989, 1, 8); static int era(int y, int m, int d) { return y * 10000 + m * 100 + d; } static String ans(int temp, int y, int m, int d) { y++; if...
import java.util.Scanner; public class Main { static int meiji = era(1868, 9, 8), taisho = era(1912, 7, 30), showa = era(1926, 12, 25), heisei = era(1989, 1, 8); static int era(int y, int m, int d) { return y * 10000 + m * 100 + d; } static String ans(int temp, int y, int m, int d) { y++; if...
[["-", 31, 16, 31, 16, 31, 16, 31, 5, 0, 491], ["+", 31, 16, 31, 16, 31, 16, 31, 5, 0, 491]]
3
337
2
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); while (stdIn.hasNext()) { int year = stdIn.nextInt(); int month = stdIn.nextInt(); int day = stdIn.nextInt(); if (year <= 1867) { System.out.printl...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); while (stdIn.hasNext()) { int year = stdIn.nextInt(); int month = stdIn.nextInt(); int day = stdIn.nextInt(); if (year <= 1867) { System.out.printl...
[["-", 31, 16, 31, 16, 31, 16, 31, 5, 0, 491], ["+", 31, 16, 31, 16, 31, 16, 31, 5, 0, 491]]
3
763
2
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Calendar; import java.util.GregorianCalendar; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Calendar; import java.util.GregorianCalendar; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ...
[["+", 75, 16, 31, 16, 31, 16, 12, 23, 0, 24], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 12, 499], ["+", 75, 16, 31, 16, 31, 16, 12, 23, 0, 25]]
3
424
4
#define _CRT_SECURE_NO_WARNINGS //#define _USE_MATH_DEFINES #include <stdio.h> //#include<stdlib.h> //#include<math.h> //#include<string.h> //#include<time.h> //#include<ctype.h> //#define pi acos(-1.0) #define P(type, x) fprintf(stdout, "%" #type "\n", x) #define S(type, x) fscanf(stdin, "%" #type, &x) //#define MAX(a...
#define _CRT_SECURE_NO_WARNINGS //#define _USE_MATH_DEFINES #include <stdio.h> //#include<stdlib.h> //#include<math.h> //#include<string.h> //#include<time.h> //#include<ctype.h> //#define pi acos(-1.0) #define P(type, x) fprintf(stdout, "%" #type "\n", x) #define S(type, x) fscanf(stdin, "%" #type, &x) //#define MAX(a...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
220
4
#include <stdio.h> // printf(), scanf() int main(int argc, char **argv) { int y, m, d; while (scanf("%d %d %d", &y, &m, &d) != EOF) { if (y > 1989 || (y == 1989 && (m > 1 || (m == 1 && d >= 8)))) printf("heisei %d %d %d\n", y - 1988, m, d); else if (y > 1926 || (y == 1926 && (m == 12 && d >= 25))) ...
#include <stdio.h> // printf(), scanf() int main(int argc, char **argv) { int y, m, d; while (scanf("%d %d %d", &y, &m, &d) != EOF) { if (y > 1989 || (y == 1989 && (m > 1 || (m == 1 && d >= 8)))) printf("heisei %d %d %d\n", y - 1988, m, d); else if (y > 1926 || (y == 1926 && m == 12 && d >= 25)) ...
[["-", 0, 16, 12, 23, 0, 16, 12, 23, 0, 24], ["-", 0, 16, 12, 23, 0, 16, 12, 23, 0, 25], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
230
4
#include <math.h> #include <stdio.h> int main(void) { int y, m, d, D; while (scanf("%d %d %d", &y, &m, &d) != EOF) { D = 10000 * y + m * 100 + d; /*printf("D%d", D);*/ if (D < 18680908) printf("pre-meiji\n"); else if (18680908 <= D && D <= 19120729) printf("meiji %d %d d\n", y - 1867, m,...
#include <math.h> #include <stdio.h> int main(void) { int y, m, d, D; while (scanf("%d %d %d", &y, &m, &d) != EOF) { D = 10000 * y + m * 100 + d; /*printf("D%d", D);*/ if (D < 18680908) printf("pre-meiji\n"); else if (18680908 <= D && D <= 19120729) printf("meiji %d %d %d\n", y - 1867, m...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
177
2
#include <stdio.h> int main(void) { int y, m, d; while (scanf("%d %d %d", &y, &m, &d) != EOF) { if (y < 1868) printf("pre-meiji\n"); else if (y == 1868 && m < 9) printf("pre-meiji\n"); else if (y == 1868 && m == 9 && d < 8) printf("pre-meiji\n"); else if (y < 1912) printf("...
#include <stdio.h> int main(void) { int y, m, d; while (scanf("%d %d %d", &y, &m, &d) != EOF) { if (y < 1868) printf("pre-meiji\n"); else if (y == 1868 && m < 9) printf("pre-meiji\n"); else if (y == 1868 && m == 9 && d < 8) printf("pre-meiji\n"); else if (y < 1912) printf("...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
357
6
#include <stdio.h> int main(void) { int year, month, date; while (1) { if (scanf("%d %d %d", &year, &month, &date) == -1) break; switch (year) { case 1868: if (month > 9 || (month == 9 && date >= 8)) { printf("meizi 1 %d %d\n", month, date); } else { printf("pre-meiji\...
#include <stdio.h> int main(void) { int year, month, date; while (1) { if (scanf("%d %d %d", &year, &month, &date) == -1) break; switch (year) { case 1868: if (month > 9 || (month == 9 && date >= 8)) { printf("meiji 1 %d %d\n", month, date); } else { printf("pre-meiji\...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
375
2
#include <stdio.h> int main(void) { int y, m, d; long int num; while (scanf("%d %d %d", &y, &m, &d) != EOF) { num = y * 1e4 + m * 100 + d; if (num < 18680908) { printf("pre-meiji\n"); } else if (num < 19120730) { printf("meiji %d %d %d\n", y - 1868 + 1, m, d); } else if (num < 1926125...
#include <stdio.h> int main(void) { int y, m, d; long int num; while (scanf("%d %d %d", &y, &m, &d) != EOF) { num = y * 1e4 + m * 100 + d; if (num < 18680908) { printf("pre-meiji\n"); } else if (num < 19120730) { printf("meiji %d %d %d\n", y - 1868 + 1, m, d); } else if (num < 1926122...
[["-", 75, 76, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 75, 76, 0, 57, 15, 23, 0, 16, 12, 13]]
0
175
2
#include <stdio.h> int main(void) { int year, month, date, detail; while (scanf("%d%d%d", &year, &month, &date) != EOF) { detail = year * 10000 + month * 100 + date; if (detail < 18680908) { printf("pri-meiji\n"); } else if (detail < 19120730) { printf("meiji %d %d %d\n", year - 1867, mont...
#include <stdio.h> int main(void) { int year, month, date, detail; while (scanf("%d%d%d", &year, &month, &date) != EOF) { detail = year * 10000 + month * 100 + date; if (detail < 18680908) { printf("pre-meiji\n"); } else if (detail < 19120730) { printf("meiji %d %d %d\n", year - 1867, mont...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
167
2
#include <stdio.h> int main() { int y, m, d; while ((scanf("%d%d%d", &y, &m, &d)) != EOF) { if (y < 1868 || y == 1868 && m < 9 || y == 1868 && m == 9 && d < 8) printf("pre-meiji\n"); else if (y < 1912 || y == 1912 && m < 7 || y == 1912 && m == 7 && d < 30) printf("meiji %d %d %d\n", y - 1867, m,...
#include <stdio.h> int main() { int y, m, d; while ((scanf("%d%d%d", &y, &m, &d)) != EOF) { if (y < 1868 || y == 1868 && m < 9 || y == 1868 && m == 9 && d < 8) printf("pre-meiji\n"); else if (y < 1912 || y == 1912 && m < 7 || y == 1912 && m == 7 && d < 30) printf("meiji %d %d %d\n", y - 1867, m,...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
214
2
// include // ---------------------------------------------------------------------------- #include <ctype.h> #include <math.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> // repetition // ---------------------------------------------------------------------------- #define FOR(i, a,...
// include // ---------------------------------------------------------------------------- #include <ctype.h> #include <math.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> // repetition // ---------------------------------------------------------------------------- #define FOR(i, a,...
[["-", 0, 57, 15, 23, 0, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 47]]
0
755
2
#include <stdio.h> main() { int a, b, c; int meiji = 1868, taisho = 1912, showa = 1926, heisei = 1989; while (scanf("%d %d %d", &a, &b, &c) != EOF) { if ((a <= 1867) || (a == 1868 && b < 9) || (a == 1868 && b == 9 && c <= 7)) { printf("pre-meiji\n"); } else if ((a <= 1911) || (a == 1912 && b...
#include <stdio.h> main() { int a, b, c; int meiji = 1868, taisho = 1912, showa = 1926, heisei = 1989; while (scanf("%d %d %d", &a, &b, &c) != EOF) { if ((a <= 1867) || (a == 1868 && b < 9) || (a == 1868 && b == 9 && c <= 7)) { printf("pre-meiji\n"); } else if ((a <= 1911) || (a == 1912 && b...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
269
2
#include <stdio.h> int main() { int y, m, d, num; while (scanf("%d %d %d %d", &y, &m, &d) != EOF) { num = y * 10000 + m * 100 + d; if (num < 18680908) puts("pre-meiji"); else if (num < 19120730) printf("meiji %d %d %d\n", y - 1867, m, d); else if (num < 19261225) printf("taisho %d ...
#include <stdio.h> int main() { int y, m, d, num; while (scanf("%d %d %d", &y, &m, &d) != EOF) { num = y * 10000 + m * 100 + d; if (num < 18680908) puts("pre-meiji"); else if (num < 19120730) printf("meiji %d %d %d\n", y - 1867, m, d); else if (num < 19261225) printf("taisho %d %d ...
[["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6]]
0
153
2
#include <stdio.h> int main(void) { int year, month, date; while (scanf("%d %d %d", &year, &month, &date) != EOF) { if (year < 1868 || (year == 1868 && (month < 9 || (month == 9 && date < 8)))) { printf("pre-meiji\n"); } else if (year < 1912 || (year == 1912 && (month < 7 || (mo...
#include <stdio.h> int main(void) { int year, month, date; while (scanf("%d %d %d", &year, &month, &date) != EOF) { if (year < 1868 || (year == 1868 && (month < 9 || (month == 9 && date < 8)))) { printf("pre-meiji\n"); } else if (year < 1912 || (year == 1912 && (month < 7 || (mo...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
239
2
#include <cstdio> #include <utility> using namespace std; #define gcu getchar_unlocked #define pcu putchar_unlocked #define _T template <typename T> #define _HT template <typename H, typename... T> #define _il inline #define _in _il int in #define _sc _il bool scan _T T in(int c) { T n = 0; bool m = false; if (c...
#include <cstdio> #include <utility> using namespace std; #define gcu getchar_unlocked #define pcu putchar_unlocked #define _T template <typename T> #define _HT template <typename H, typename... T> #define _il inline #define _in _il int in #define _sc _il bool scan _T T in(int c) { T n = 0; bool m = false; if (c...
[["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117]]
1
679
2
#include <stdbool.h> #include <stdio.h> #define Pre 0 // for switch #define Meiji 1 #define Taisho 2 #define Showa 3 #define Heisei 4 // declare function void print_gengo(int nen, int tuki, int hi); /*==============end of delaration====================================*/ int main(void) { int impyear; int impmont...
#include <stdbool.h> #include <stdio.h> #define Pre 0 // for switch #define Meiji 1 #define Taisho 2 #define Showa 3 #define Heisei 4 // declare function void print_gengo(int nen, int tuki, int hi); /*==============end of delaration====================================*/ int main(void) { int impyear; int impmont...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
353
2
#include <stdbool.h> #include <stdio.h> const int ERA_PRE_MEIJI = -1; const int ERA_MEIJI = 0; const int ERA_TAISHO = 1; const int ERA_SHOWA = 2; const int ERA_HEISEI = 3; const int ERA_BEGIN_YEAR[] = {1868, 1912, 1926, 1989}; const int ERA_BEGIN_MONTH[] = {9, 7, 12, 1}; const int ERA_BEGIN_DATE[] = {8, 30, 25, 8}; ...
#include <stdbool.h> #include <stdio.h> const int ERA_PRE_MEIJI = -1; const int ERA_MEIJI = 0; const int ERA_TAISHO = 1; const int ERA_SHOWA = 2; const int ERA_HEISEI = 3; const int ERA_BEGIN_YEAR[] = {1868, 1912, 1926, 1989}; const int ERA_BEGIN_MONTH[] = {9, 7, 12, 1}; const int ERA_BEGIN_DATE[] = {8, 30, 25, 8}; ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
508
2
#include <iostream> #include <string> #define loop(i, a, b) for (int i = a; i < b; i++) using namespace std; const int Yb = 0; const int Mb = 1; const int Db = 2; const int Ye = 3; const int Me = 4; const int De = 5; const int table[4][6] = {{1868, 9, 8, 1912, 7, 29}, {1912, 7, 30, 1926, 12,...
#include <iostream> #include <string> #define loop(i, a, b) for (int i = a; i < b; i++) using namespace std; const int Yb = 0; const int Mb = 1; const int Db = 2; const int Ye = 3; const int Me = 4; const int De = 5; const int table[4][6] = {{1868, 9, 8, 1912, 7, 29}, {1912, 7, 30, 1926, 12,...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 51, 16, 12, 23, 0, 16, 12, 16, 17, 18], ["+", 51, 16, 12, 23, 0, 16, 12, 16, 17, 19], ["-", 12, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["-", 12, 69, 28, 69, 341, 342, 0, 16, 12, 13], ["-", 12, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 1...
1
423
8
#include <iostream> using namespace std; int main() { int y, m, d; string str[] = {"pre-meiji", "meiji", "taisho", "showa", "heisei"}; while (cin >> y >> m >> d) { int p = y * 10000 + m * 100 + d, c; if (p < 18680908) c = 0; else if (p < 19120730) c = 1; else if (p < 19261225) c ...
#include <iostream> using namespace std; int main() { int y, m, d; string str[] = {"pre-meiji", "meiji", "taisho", "showa", "heisei"}; while (cin >> y >> m >> d) { int p = y * 10000 + m * 100 + d, c; if (p < 18680908) c = 0; else if (p < 19120730) c = 1; else if (p < 19261225) c ...
[["+", 0, 99, 8, 9, 0, 100, 0, 93, 0, 94], ["+", 0, 99, 8, 9, 0, 100, 0, 93, 0, 35], ["+", 0, 99, 8, 9, 0, 100, 0, 1, 0, 35]]
1
220
6
#include <stdio.h> int main() { int x, y, z; int n1 = 0, m1 = 0; while (scanf("%d %d %d", &x, &y, &z) != EOF) { n1 = 10000 * x + 100 * y + z; if (n1 >= 19890108) { printf("heisei "); x = x - 1988; } else if (n1 >= 19261225) { printf("showa "); x = x - 1925; } else if (n1 ...
#include <stdio.h> int main() { int x, y, z; int n1 = 0, m1 = 0; while (scanf("%d %d %d", &x, &y, &z) != EOF) { n1 = 10000 * x + 100 * y + z; if (n1 >= 19890108) { printf("heisei "); x = x - 1988; } else if (n1 >= 19261225) { printf("showa "); x = x - 1925; } else if (n1 ...
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
187
2
#include <stdio.h> char judge(int year, int month, int day); int main(void) { int year, month, day; char era; while (scanf("%d %d %d", &year, &month, &day) != EOF) { era = judge(year, month, day); if (era == 'p') { printf("pre-meii\n"); } else if (era == 'm') { printf("meiji %d %d %d\n",...
#include <stdio.h> char judge(int year, int month, int day); int main(void) { int year, month, day; char era; while (scanf("%d %d %d", &year, &month, &day) != EOF) { era = judge(year, month, day); if (era == 'p') { printf("pre-meiji\n"); } else if (era == 'm') { printf("meiji %d %d %d\n"...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
497
2
#include <stdio.h> void wareki_convert(int year, int month, int day); int main(void) { int year, month, day; while (scanf("%d %d %d", &year, &month, &day) != EOF) { wareki_convert(year, month, day); } return 0; } void wareki_convert(int year, int month, int day) { if (year <= 1867 || (year == 1868 && m...
#include <stdio.h> void wareki_convert(int year, int month, int day); int main(void) { int year, month, day; while (scanf("%d %d %d", &year, &month, &day) != EOF) { wareki_convert(year, month, day); } return 0; } void wareki_convert(int year, int month, int day) { if (year <= 1867 || (year == 1868 && m...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
301
2
#include <stdbool.h> #include <stdint.h> #include <stdio.h> void transferToGengo(int, int, int); int main(void) { int year, month, day; while (scanf("%d%d%d", &year, &month, &day) != EOF) { transferToGengo(year, month, day); } return 0; } void transferToGengo(int year, int month, int day) { //年月日をくっつ...
#include <stdbool.h> #include <stdint.h> #include <stdio.h> void transferToGengo(int, int, int); int main(void) { int year, month, day; while (scanf("%d%d%d", &year, &month, &day) != EOF) { transferToGengo(year, month, day); } return 0; } void transferToGengo(int year, int month, int day) { //年月日をくっつ...
[["-", 75, 76, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 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]]
1
210
5
#include <iostream> #include <string> using namespace std; int main() { int y, m, d; while (cin >> y >> m >> d) { if (y >= 1990 || (y == 1989 && m >= 2) || (y == 1989 && m == 1 && d >= 8)) { cout << "heisei " << y - 1989 + 1 << " " << m << " " << d << endl; } else if (y >= 1927 || (y == 1926 && m == ...
#include <iostream> #include <string> using namespace std; int main() { int y, m, d; while (cin >> y >> m >> d) { if (y >= 1990 || (y == 1989 && m >= 2) || (y == 1989 && m == 1 && d >= 8)) { cout << "heisei " << y - 1989 + 1 << " " << m << " " << d << endl; } else if (y >= 1927 || (y == 1926 && m == ...
[["-", 31, 16, 31, 16, 12, 16, 31, 16, 12, 13], ["+", 31, 16, 31, 16, 12, 16, 31, 16, 12, 13], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
272
4
#include <algorithm> #include <iostream> #include <list> #include <map> #include <stdio.h> #include <string.h> #include <vector> #define range(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, b) range(i, 0, b) #define debug(x) cout << x << endl; using namespace std; int main() { int year, month, day; while ...
#include <algorithm> #include <iostream> #include <list> #include <map> #include <stdio.h> #include <string.h> #include <vector> #define range(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, b) range(i, 0, b) #define debug(x) cout << x << endl; using namespace std; int main() { int year, month, day; while ...
[["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
1
319
2
#include <iostream> #include <string> using namespace std; int main() { int y, m, d, ny; string a; while (cin >> y >> m >> d) { a = "pre-meiji"; ny = y + 1; if (y > 1868 || y == 1868 && m > 9 || y == 1868 && m == 9 && d >= 8) { ny -= 1868; a = "meiji "; } if (y > 1912 || y == 1912 ...
#include <iostream> #include <string> using namespace std; int main() { int y, m, d, ny; string a; while (cin >> y >> m >> d) { a = "pre-meiji"; ny = y + 1; if (y > 1868 || y == 1868 && m > 9 || y == 1868 && m == 9 && d >= 8) { ny -= 1868; a = "meiji "; } if (y > 1912 || y == 1912 ...
[["+", 0, 52, 8, 9, 0, 57, 64, 1, 0, 35], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22]]
1
235
2
#include <stdio.h> int Y, M, D; bool is_leap(int y) { return y % 400 == 0 || (y % 4 == 0 && y % 100 != 0); } int count(int y, int m, int d) { int ret = 0; for (int i = 1; i < y; i++) { if (is_leap(i)) ret += 366; else ret += 365; } for (int i = 1; i < m; i++) { if (i == 2) ret += (...
#include <stdio.h> int Y, M, D; bool is_leap(int y) { return y % 400 == 0 || (y % 4 == 0 && y % 100 != 0); } int count(int y, int m, int d) { int ret = 0; for (int i = 1; i < y; i++) { if (is_leap(i)) ret += 366; else ret += 365; } for (int i = 1; i < m; i++) { if (i == 2) ret += (...
[["+", 0, 52, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 57, 75, 76, 0, 57, 75, 76, 0, 95]]
1
337
9
#include <iostream> using namespace std; int main() { int y, m, d; long n[4], num; n[0] = 1868 * 10000 + 9 * 100 + 8; n[1] = 1912 * 10000 + 7 * 100 + 30; n[2] = 1926 * 10000 + 12 * 100 + 25; n[3] = 1989 * 10000 + 1 * 100 + 8; cin >> y >> m >> d; num = y * 10000 + m * 100 + d; if (n[0] <= num && nu...
#include <iostream> using namespace std; int main() { int y, m, d; long n[4], num; n[0] = 1868 * 10000 + 9 * 100 + 8; n[1] = 1912 * 10000 + 7 * 100 + 30; n[2] = 1926 * 10000 + 12 * 100 + 25; n[3] = 1989 * 10000 + 1 * 100 + 8; while (cin >> y >> m >> d) { num = y * 10000 + m * 100 + d; if (n[0]...
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
281
6
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" > "D:...
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" > "D:...
[["-", 64, 9, 0, 1, 0, 11, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 11, 12, 5, 0, 6]]
1
298
2
#include <stdio.h> class Date { public: int y; int m; int d; Date(int y, int m, int d) { this->y = y; this->m = m; this->d = d; } int cmp(Date d2) { if (this->y < d2.y) return -1; if (this->y > d2.y) return 1; if (this->m < d2.m) return -1; if (this->m > d2.m)...
#include <stdio.h> class Date { public: int y; int m; int d; Date(int y, int m, int d) { this->y = y; this->m = m; this->d = d; } int cmp(Date d2) { if (this->y < d2.y) return -1; if (this->y > d2.y) return 1; if (this->m < d2.m) return -1; if (this->m > d2.m)...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
382
2
#include <cstdio> #include <iostream> #include <string> using namespace std; #define loop(i, n) for (int i = 0; i < n; i++) int main() { int a, b, c; while (cin >> a >> b >> c) { int era = 0; if (a < 1868) { era = 1; } else if (a == 1868) { if (b < 9) { era = 1; } else if (b...
#include <cstdio> #include <iostream> #include <string> using namespace std; #define loop(i, n) for (int i = 0; i < n; i++) int main() { int a, b, c; while (cin >> a >> b >> c) { int era = 0; if (a < 1868) { era = 1; } else if (a == 1868) { if (b < 9) { era = 1; } else if (b...
[["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
1
455
2
#include <stdio.h> int main() { int a, b, c; while (scanf("%d%d%d", &a, &b, &c) != EOF) { if (a > 1989) printf("heisei %d %d %d\n", a - 1988, b, c); else if (a == 1989) { if (b > 1) printf("heisei %d %d %d\n", a - 1988, b, c); else if (c >= 8) printf("heisei %d %d %d\n", a ...
#include <stdio.h> int main() { int a, b, c; while (scanf("%d%d%d", &a, &b, &c) != EOF) { if (a > 1989) printf("heisei %d %d %d\n", a - 1988, b, c); else if (a == 1989) { if (b > 1) printf("heisei %d %d %d\n", a - 1988, b, c); else if (c >= 8) printf("heisei %d %d %d\n", a ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
402
2
#include <iostream> #include <string> using namespace std; #define DATE_MEIJI_S 18680908 #define DATE_MEIJI_F 19190729 #define DATE_TAISHO_S 19190730 #define DATE_TAISHO_F 19261224 #define DATE_SHOWA_S 19261225 #define DATE_SHOWA_F 19890107 #define DATE_HEISEI_S 19890108 class CEra { public: CEra() {} void Set(s...
#include <iostream> #include <string> using namespace std; #define DATE_MEIJI_S 18680908 #define DATE_MEIJI_F 19120729 #define DATE_TAISHO_S 19120730 #define DATE_TAISHO_F 19261224 #define DATE_SHOWA_S 19261225 #define DATE_SHOWA_F 19890107 #define DATE_HEISEI_S 19890108 class CEra { public: CEra() {} void Set(s...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
1
347
4
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using ...
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using ...
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
1
354
2
#include <iostream> #include <string> using namespace std; int main() { string name[5] = {"meiji", "taisho", "showa", "heisei"}, ss = " "; int year[5] = {1867, 1911, 1925, 1988}; int a, b, c, d; while (cin >> a >> b >> c) { d = a * 10000 + b * 100 + c; if (d < 18680908) { cout << "pre-meiji" << en...
#include <iostream> #include <string> using namespace std; int main() { string name[5] = {"meiji", "taisho", "showa", "heisei"}, ss = " "; int year[5] = {1867, 1911, 1925, 1988}; int a, b, c, d; while (cin >> a >> b >> c) { d = a * 10000 + b * 100 + c; if (d < 18680908) { cout << "pre-meiji" << en...
[["+", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
230
2
#include <iostream> using namespace std; int main() { long i, j, n, nn, m, p[1000]; while (cin >> n) { cin >> m; if (n == 0) break; nn = n; for (i = 0; i < n; i++) p[i] = i; j = 0; for (;;) { for (i = 0; i < m; i++) { j++; if (j >= n) j -= n; ...
#include <iostream> using namespace std; int main() { long i, j, n, nn, m, p[1001]; while (cin >> n) { cin >> m; if (n == 0) break; nn = n; for (i = 1; i <= n; i++) p[i] = 1; j = 0; for (;;) { for (i = 0; i < m; i++) { j++; if (j > n) j -= n; ...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 8, 9, 0, 7, 8, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 7, 8, 1, 0...
1
150
10
#include <stdio.h> int main(void) { int n, m; int a[1000]; while (1) { scanf("%d %d", &n, &m); if (n == 0 && m == 0) return 0; for (int i = 0; i <= n; i++) a[i] = 0; int p = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m;) { p = (p + 1) % n; if (a[p] ...
#include <stdio.h> int main(void) { int n, m; int a[1000]; while (1) { scanf("%d %d", &n, &m); if (n == 0 && m == 0) return 0; for (int i = 0; i < n; i++) a[i] = 0; int p = -1; for (int i = 0; i < n; i++) { for (int j = 0; j < m;) { p = (p + 1) % n; if (a[p] ...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
150
6
#include <iostream> #include <vector> using namespace std; int main() { int n, m; while (cin >> n >> m && n != 0 && m != 0) { vector<bool> seki(n, true); int cn = 0; for (int i = 0; i < n - 1; i++) { int offset = 0; for (int j = 0; j < m + offset; j++) { cn++; cn = cn % n; ...
#include <iostream> #include <vector> using namespace std; int main() { int n, m; while (cin >> n >> m && n != 0 && m != 0) { vector<bool> seki(n, true); int cn = -1; for (int i = 0; i < n - 1; i++) { int offset = 0; for (int j = 0; j < m + offset; j++) { cn++; cn = cn % n; ...
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 64, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 64, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
152
4
readlines.each do |l| n,m = l.split.map(&:to_i) break if n==0 && m==0 i = n p = (0..(n-1)).to_a while p.size>1 p.delete_at(i=((i+m) % p.size)) i = (i-1) % p.size end puts p.first end
readlines.each do |l| n,m = l.split.map(&:to_i) break if n==0 && m==0 i = -1 p = (0..(n-1)).to_a while p.size>1 p.delete_at(i=((i+m) % p.size)) i = (i-1) % p.size end puts p.first+1 end
[["-", 0, 652, 196, 737, 8, 736, 0, 662, 12, 22], ["+", 196, 737, 8, 736, 0, 662, 12, 748, 17, 33], ["+", 196, 737, 8, 736, 0, 662, 12, 748, 439, 612], ["+", 8, 736, 0, 652, 3, 4, 0, 738, 17, 72], ["+", 8, 736, 0, 652, 3, 4, 0, 738, 12, 612]]
4
86
5
while True: n,m = input().split() n = int(n) m = int(m) if n==m==0: break l = [i for i in range(n)] c = 0 while len(l) >= 2: c = (c+m)%len(l) l.pop(c) c -= 1 print(l[0])
while True: n,m = input().split() n = int(n) m = int(m) if n==m==0: break l = [i for i in range(n)] c = -1 while len(l) >= 2: c = (c+m)%len(l) l.pop(c) c -= 1 print(l[0]+1)
[["-", 0, 52, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 8, 196, 0, 1, 0, 662, 12, 664, 17, 33], ["+", 8, 196, 0, 1, 0, 662, 12, 664, 28, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
85
5
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import (division, absolute_import, print_function, unicode_literals) from sys import stdin for line in stdin: n, m = (int(s) for s in line.split()) if not (n or m): break ary = bytearray(b'\x01'*n) index = n ...
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import (division, absolute_import, print_function, unicode_literals) from sys import stdin for line in stdin: n, m = (int(s) for s in line.split()) if not (n or m): break ary = bytearray(b'\x01'*n) index = n -...
[["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 33], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
103
4
import java.io.*; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.NoSuchElementException; import java.util.Scanner; public class Main { public static void mai...
import java.io.*; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.NoSuchElementException; import java.util.Scanner; public class Main { public static void mai...
[["+", 3, 4, 0, 510, 15, 23, 0, 16, 17, 98], ["+", 0, 510, 15, 23, 0, 16, 12, 16, 31, 22], ["+", 0, 510, 15, 23, 0, 16, 12, 16, 17, 60], ["+", 0, 510, 15, 23, 0, 16, 12, 16, 12, 499]]
3
914
4
import java.io.*; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.NoSuchElementException; import java.util.Scanner; public class Main { public static void mai...
import java.io.*; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.NoSuchElementException; import java.util.Scanner; public class Main { public static void mai...
[["-", 0, 16, 31, 16, 31, 16, 31, 504, 71, 499], ["+", 0, 16, 31, 16, 31, 16, 31, 504, 71, 499], ["-", 0, 16, 12, 16, 31, 16, 31, 504, 71, 499], ["+", 0, 16, 12, 16, 31, 16, 31, 504, 71, 499], ["-", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499], ["+", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499]]
3
911
6
import java.util.*; class Main { Scanner sc = new Scanner(System.in); public void run() { while (sc.hasNext()) { boolean[] odd = new boolean[101]; while (true) { int f = sc.nextInt(), t = sc.nextInt(); if (f == 0 && t == 0) break; odd[f] = !odd[f]; odd[t] =...
import java.util.*; class Main { Scanner sc = new Scanner(System.in); public void run() { while (sc.hasNext()) { boolean[] odd = new boolean[101]; while (true) { int f = sc.nextInt(), t = sc.nextInt(); if (f == 0 && t == 0) break; odd[f] = !odd[f]; odd[t] =...
[["-", 0, 1, 0, 11, 12, 16, 31, 91, 17, 111], ["-", 0, 1, 0, 11, 12, 16, 12, 91, 17, 111], ["+", 8, 196, 0, 1, 0, 11, 12, 91, 17, 111]]
3
237
3
/* AizuOnline A0086 Title Patrol */ #include <stdio.h> // Select Below //#include <stdlib.h> #include <string.h> //#include <float.h> //#include <math.h> //#include <limits.h> // Global data section #define NO_OF_CROSS 100 int hist[NO_OF_CROSS]; // main() { int c1, c2, i, ans; memset(hist, 0, sizeof(hist)); whil...
/* AizuOnline A0086 Title Patrol */ #include <stdio.h> // Select Below //#include <stdlib.h> #include <string.h> //#include <float.h> //#include <math.h> //#include <limits.h> // Global data section #define NO_OF_CROSS 100 int hist[NO_OF_CROSS]; // main() { int c1, c2, i, ans; memset(hist, 0, sizeof(hist)); whil...
[["-", 0, 2, 3, 4, 0, 41, 64, 5, 0, 6], ["+", 0, 2, 3, 4, 0, 41, 64, 5, 0, 6], ["-", 0, 2, 3, 4, 0, 41, 75, 5, 0, 6], ["+", 0, 2, 3, 4, 0, 41, 75, 5, 0, 6]]
0
243
4
#include <cstring> #include <iostream> using namespace std; int list[100]; int main(void) { int a, b; bool flag = false; while (cin >> a >> b) { memset(list, 0, 100); list[a - 1]++; list[b - 1]++; while (true) { cin >> a >> b; if (!a && !b) break; list[a - 1]++; l...
#include <cstring> #include <iostream> using namespace std; int list[100]; int main(void) { int a, b; bool flag = false; while (cin >> a >> b) { memset(list, 0, 100); list[a - 1]++; list[b - 1]++; while (true) { cin >> a >> b; if (!a && !b) break; list[a - 1]++; l...
[["+", 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, 147], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
182
4
#include <iostream> using namespace std; int x[200], a, b; int main() { while (cin >> a >> b) { for (int i = 0; i < 200; i++) x[i] = 0; x[a]++; x[b]++; while (true) { cin >> a >> b; if (a == 0) { break; } x[a]++; x[b]++; } int F = 0; for (int i =...
#include <iostream> using namespace std; int x[200], a, b; int main() { while (cin >> a >> b) { for (int i = 0; i < 200; i++) x[i] = 0; x[a]++; x[b]++; while (true) { cin >> a >> b; if (a == 0) { break; } x[a]++; x[b]++; } int F = 0; for (int i =...
[["-", 15, 339, 51, 16, 12, 16, 31, 16, 12, 13], ["+", 15, 339, 51, 16, 12, 16, 31, 16, 12, 13]]
1
182
2
#include <iostream> using namespace std; int main() { int a, b; int hen[100] = {}; while (cin >> a >> b) { hen[a - 1]++; hen[b - 1]++; if (a == 0) { if (hen[0] % 2 == 1 && hen[1] % 2 == 1) { for (int i = 2; i < 101; i++) { if (i < 100 && hen[i] % 2 == 1) { cout << ...
#include <iostream> using namespace std; int main() { int a, b; int hen[100] = {0}; while (cin >> a >> b) { hen[a - 1]++; hen[b - 1]++; if (a == 0) { if (hen[0] % 2 == 1 && hen[1] % 2 == 1) { for (int i = 2; i < 101; i++) { if (i < 100 && hen[i] % 2 == 1) { cout <<...
[["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 0, 57, 64, 9, 0, 7, 8, 9, 0, 46], ["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46], ["-", 0, 57, 64, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46]]
1
172
5
#include <iostream> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) using namespace std; int main() { while (1) { int a = -1, b; int dt[101] = {0}; while (cin >> a >> b && a || b) { dt[a]++; dt[b]++; } if (a == -1) return 0; bool flg = true;...
#include <iostream> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) using namespace std; int main() { while (1) { int a = -1, b; int dt[101] = {0}; while (cin >> a >> b && a || b) { dt[a]++; dt[b]++; } if (a == -1) return 0; bool flg = true;...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35], ["+", 0, 52, 8, 9, 0, 57, ...
1
172
8
#include <bits/stdc++.h> #define range(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, b) range(i, 0, b) #define itrep(it, a) for (it = (a).begin(); it != (a).end(); it++) #define all(a) (a).begin(), (a).end() #define debug(x) cout << "debug " << x << endl; #define INF (1 << 30) using namespace std; #define N ...
#include <bits/stdc++.h> #define range(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, b) range(i, 0, b) #define itrep(it, a) for (it = (a).begin(); it != (a).end(); it++) #define all(a) (a).begin(), (a).end() #define debug(x) cout << "debug " << x << endl; #define INF (1 << 30) using namespace std; #define N ...
[["-", 31, 16, 31, 16, 31, 69, 341, 342, 0, 13], ["+", 31, 16, 31, 16, 31, 69, 341, 342, 0, 13], ["-", 12, 16, 31, 16, 31, 69, 341, 342, 0, 13], ["+", 12, 16, 31, 16, 31, 69, 341, 342, 0, 13]]
1
216
4
#include <algorithm> // sort ????????? #include <iostream> #include <string> // string (?????????) ????????? using namespace std; int N[256] = {0}, a, b; bool ok() { if (N[1] % 2 == 0) return false; if (N[2] % 2 == 0) return false; for (int i = 3; i < 256; i++) { if (N[i] % 2 == 1) return false;...
#include <algorithm> // sort ????????? #include <iostream> #include <string> // string (?????????) ????????? using namespace std; int N[256] = {0}, a, b; bool ok() { if (N[1] % 2 == 0) return false; if (N[2] % 2 == 0) return false; for (int i = 3; i < 256; i++) { if (N[i] % 2 == 1) return false;...
[["+", 0, 57, 15, 339, 51, 2, 3, 4, 0, 24], ["+", 0, 57, 15, 339, 51, 2, 3, 4, 0, 25]]
1
180
2
#include <bits/stdc++.h> using namespace std; int main() { while (1) { int a[120] = {0}, s, t; while (cin >> s >> t, s) a[s]++, a[t]++; if (a[0] == 0) return 0; for (int i = 3; i < 120; i++) if (a[i] % 2 || !(a[0] % 2 && a[1] % 2)) goto L; cout << "OK" << endl; if (0)...
#include <bits/stdc++.h> using namespace std; int main() { while (1) { int a[120] = {0}, s, t; while (cin >> s >> t, s) a[s]++, a[t]++; if (a[1] == 0) return 0; for (int i = 3; i < 120; i++) if (a[i] % 2 || !(a[1] % 2 && a[2] % 2)) goto L; cout << "OK" << endl; if (0)...
[["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13], ["-", 0, 16, 31, 16, 31, 69, 341, 342, 0, 13], ["+", 0, 16, 31, 16, 31, 69, 341, 342, 0, 13], ["-", 0, 16, 12, 16, 31, 69, 341, 342, 0, 13], ["+", 0, 16, 12, 16, 31, 69, 341, 342, 0, 13]]
1
131
6
#include <iostream> using namespace std; int map[110]; bool solve() { if (map[1] % 2 == map[2] & 2 == 1) { for (int i = 3; i <= 100; i++) { if (map[i] % 2 == 1) return false; } return true; } else return false; } int main() { int a, b; while (cin >> a >> b) { if (!a && !b) { ...
#include <iostream> using namespace std; int map[110]; bool solve() { if (map[1] % 2 == 1 && map[2] % 2 == 1) { for (int i = 3; i <= 100; i++) { if (map[i] % 2 == 1) return false; } return true; } else return false; } int main() { int a, b; while (cin >> a >> b) { if (!a && !b)...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 67], ["+", 15, 339, 51, 16, 12, 16, 31, 16, 17, 109]]
1
165
4
#include <bits/stdc++.h> using namespace std; int main() { int a, b; map<int, int> deg; while (cin >> a >> b) { if (a == 0 && b == 0) { bool f = true; for (auto p : deg) { if (p.first < 2 && !(p.second & 1)) f = false; if (p.first >= 2 && p.second & 1) f = fal...
#include <bits/stdc++.h> using namespace std; int main() { int a, b; map<int, int> deg; while (cin >> a >> b) { if (a == 0 && b == 0) { bool f = true; for (auto p : deg) { if (p.first < 2 && ~p.second & 1) f = false; if (p.first >= 2 && p.second & 1) f = false...
[["-", 0, 57, 15, 339, 51, 16, 12, 91, 17, 111], ["-", 15, 339, 51, 16, 12, 91, 28, 23, 0, 24], ["+", 15, 339, 51, 16, 12, 16, 31, 91, 17, 92], ["-", 15, 339, 51, 16, 12, 91, 28, 23, 0, 25], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117]]
1
140
6
#include <iostream> #define CROSS 101 using namespace std; int main() { int a, b; int data[CROSS][CROSS]; int initFlag = true; while (cin >> a >> b) { if (initFlag) { for (int i = 0; i < CROSS; i++) { for (int j = 0; j < CROSS; j++) { data[i][j] = 0; } } initFlag...
#include <iostream> #define CROSS 101 using namespace std; int main() { int a, b; int data[CROSS][CROSS]; int initFlag = true; while (cin >> a >> b) { if (initFlag) { for (int i = 0; i < CROSS; i++) { for (int j = 0; j < CROSS; j++) { data[i][j] = 0; } } initFlag...
[["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 146], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
253
4
#include <iostream> #include <map> using namespace std; int main(void) { int u, v; map<int, int> m; while (cin >> u >> v) { if (u == 0 && v == 0) { bool flag = true; map<int, int>::iterator it; for (it = m.begin(); it != m.end(); it++) { if (it->first == 1 && it->second % 2 == 0) ...
#include <iostream> #include <map> using namespace std; int main(void) { int u, v; map<int, int> m; while (cin >> u >> v) { if (u == 0 && v == 0) { bool flag = true; map<int, int>::iterator it; for (it = m.begin(); it != m.end(); it++) { if (it->first == 1 && it->second % 2 == 0) ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
196
2
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <sstream> #include <string> #include <vector> #define rep(x, to) for (int x = 0; x < to; x++) #define rep2(x, from, to) for (int x = from; x < to; x++) using namespace std; int main(void) { int a, b; while (!cin.eof()) { if...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <sstream> #include <string> #include <vector> #define rep(x, to) for (int x = 0; x < to; x++) #define rep2(x, from, to) for (int x = from; x < to; x++) using namespace std; int main(void) { int a, b; while (!cin.eof()) { if...
[["-", 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
231
4
#include <algorithm> #include <cmath> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <time.h> using namespace std; #define INF 10000000 typedef long long ll; int n[101]; int main() { int a, b, flg; while (1) { flg = 0; for (int i = 0; i < 101;...
#include <algorithm> #include <cmath> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <time.h> using namespace std; #define INF 10000000 typedef long long ll; int n[101]; int main() { int a, b, flg; while (1) { flg = 0; for (int i = 0; i < 101;...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 67], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 17, 109], ["+", 15, 339, 51, 16, 12, 16, 31, 16, 17, 109], ["+", 15, 339, 51, 16, 12, 16, 31, 16, 12, 13]]
1
209
4