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);
cout << fixed << x << endl;
}
return 0;
}
|
#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);
cout << fixed << x << endl;
}
return 0;
}
|
[["-", 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 (n < 0)
return n *= -1;
return n;
}
int main() {
int q;
double x;
while (cin >> q, q != -1) {
x = q / 2;
while (abso(x * x * x - q) >= 0.00001 * q) {
x = x - ((x * x * x - q) / (3 * x * x));
}
printf("%.16lf\n", x);
}
return 0;
}
|
#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 (n < 0)
return n *= -1;
return n;
}
int main() {
int q;
double x;
while (cin >> q, q != -1) {
x = (double)q / 2.0;
while (abso(x * x * x - q) >= 0.00001 * q) {
x = x - ((x * x * x - q) / (3 * x * x));
}
printf("%.16lf\n", x);
}
return 0;
}
|
[["+", 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) < (n); (i)++)
#define rrev(i, m, n) for (int(i) = (n)-1; (i) >= (m); (i)--)
#define erev(i, m, n) for (int(i) = (n); (i) >= (m); (i)--)
#define rev(i, n) for (int(i) = (n)-1; (i) >= 0; (i)--)
#define vrep(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ALL(v) (v).begin(), (v).end()
#define mp make_pair
#define pb push_back
template <class T, class S> inline bool minup(T &m, S x) {
return m > (T)x ? (m = (T)x, true) : false;
}
template <class T, class S> inline bool maxup(T &m, S x) {
return m < (T)x ? (m = (T)x, true) : false;
}
const int INF = 1000000000;
const ll MOD = 1000000007LL;
const double EPS = 1E-5;
double q;
double prev;
template <typename T> T add(T x, T y) {
if (abs(x + y) < EPS * q * (abs(x) + abs(y)))
return 0;
return x + y;
}
template <typename T> inline bool semieq(T x, T y) {
return abs(x - y) < EPS * q;
}
template <typename T> inline bool semige(T x, T y) { return x - y > -EPS; }
template <typename T> inline bool semile(T x, T y) { return y - x > -EPS; }
inline double next(double x, double q) {
return x - ((x * x * x - q) / (3 * x * x));
}
int main() {
while ((cin >> q) && q > 0.0) {
double res = q / 2.0;
while (!semieq(res, next(res, q)))
res = next(res, q);
printf("%.15f\n", res);
}
return 0;
}
|
#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) < (n); (i)++)
#define rrev(i, m, n) for (int(i) = (n)-1; (i) >= (m); (i)--)
#define erev(i, m, n) for (int(i) = (n); (i) >= (m); (i)--)
#define rev(i, n) for (int(i) = (n)-1; (i) >= 0; (i)--)
#define vrep(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ALL(v) (v).begin(), (v).end()
#define mp make_pair
#define pb push_back
template <class T, class S> inline bool minup(T &m, S x) {
return m > (T)x ? (m = (T)x, true) : false;
}
template <class T, class S> inline bool maxup(T &m, S x) {
return m < (T)x ? (m = (T)x, true) : false;
}
const int INF = 1000000000;
const ll MOD = 1000000007LL;
const double EPS = 1E-5;
double q;
double prev;
template <typename T> T add(T x, T y) {
if (abs(x + y) < EPS * q * (abs(x) + abs(y)))
return 0;
return x + y;
}
template <typename T> inline bool semieq(T x, T y) {
return abs(x - y) < EPS * q;
}
template <typename T> inline bool semige(T x, T y) { return x - y > -EPS; }
template <typename T> inline bool semile(T x, T y) { return y - x > -EPS; }
inline double next(double x, double q) {
return x - ((x * x * x - q) / (3 * x * x));
}
int main() {
while ((cin >> q) && q > 0.0) {
double res = q / 2.0;
while (!semieq(res * res * res, q))
res = next(res, q);
printf("%.15f\n", res);
}
return 0;
}
|
[["-", 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)));
}
printf("%.6f\n", x);
} else
break;
}
}
|
#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, 2)));
}
printf("%.6f\n", x);
}
else
break;
}
}
|
[["+", 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_Download\Visual
// Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
/* ??????????????¬ */
#include <complex>
typedef complex<ld> Point;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ld pi = acos(-1.0);
const ld dtop = pi / 180.;
const ld ptod = 1. / dtop;
namespace std {
bool operator<(const Point &lhs, const Point &rhs) {
if (lhs.real() < rhs.real() - eps)
return true;
if (lhs.real() > rhs.real() + eps)
return false;
return lhs.imag() < rhs.imag();
}
} // namespace std
// ????????\???
Point input_Point() {
ld x, y;
cin >> x >> y;
return Point(x, y);
}
// ????????????????????????
bool eq(const ld a, const ld b) { return (abs(a - b) < eps); }
// ??????
ld dot(const Point &a, const Point &b) { return real(conj(a) * b); }
// ??????
ld cross(const Point &a, const Point &b) { return imag(conj(a) * b); }
// ??´????????????
class Line {
public:
Point a, b;
Line() : a(Point(0, 0)), b(Point(0, 0)) {}
Line(Point a, Point b) : a(a), b(b) {}
Point operator[](const int _num) const {
if (_num == 0)
return a;
else if (_num == 1)
return b;
else {
assert(false);
return Point();
}
}
};
// ????????????
class Circle {
public:
Point p;
ld r;
Circle() : p(Point(0, 0)), r(0) {}
Circle(Point p, ld r) : p(p), r(r) {}
};
// ccw
// 1: a,b,c??????????¨???¨?????????????????¶
//-1: a,b,c???????¨???¨?????????????????¶
// 2: c,a,b???????????´???????????¶
//-2: a,b,c???????????´???????????¶
// 0: a,c,b???????????´???????????¶
int ccw(const Point &a, const Point &b, const Point &c) {
const Point nb(b - a);
const Point nc(c - a);
if (cross(nb, nc) > eps)
return 1; // a,b,c??????????¨???¨?????????????????¶
if (cross(nb, nc) < -eps)
return -1; // a,b,c???????¨???¨?????????????????¶
if (dot(nb, nc) < 0)
return 2; // c,a,b???????????´???????????¶
if (norm(nb) < norm(nc))
return -2; // a,b,c???????????´???????????¶
return 0; // a,c,b???????????´???????????¶
}
/* ???????????? */
// ??´?????¨??´??????????????????
bool isis_ll(const Line &l, const Line &m) {
return !eq(cross(l.b - l.a, m.b - m.a), 0);
}
// ??´?????¨?????????????????????
bool isis_ls(const Line &l, const Line &s) {
return isis_ll(l, s) &&
(cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}
// ????????¨?????????????????????
bool isis_ss(const Line &s, const Line &t) {
return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}
// ????????´????????????
bool isis_lp(const Line &l, const Point &p) {
return (abs(cross(l.b - p, l.a - p)) < eps);
}
// ?????????????????????
bool isis_sp(const Line &s, const Point &p) {
return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}
// ??????????¶?
Point proj(const Line &l, const Point &p) {
ld t = dot(p - l.a, l.b - l.a) / norm(l.a - l.b);
return l.a + t * (l.b - l.a);
}
//???????±??????????????????????
Point reflect(const Line &l, const Point &p) {
Point pr = proj(l, p);
return pr * 2.l - p;
}
// ??´?????¨??´????????????
Point is_ll(const Line &s, const Line &t) {
Point sv = s.b - s.a, tv = t.b - t.a;
assert(cross(sv, tv) != 0);
return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}
// ??´?????¨??´????????????
vector<Point> is_ll2(const Line &s, const Line &t) {
Point sv = s.b - s.a, tv = t.b - t.a;
if (cross(sv, tv) != 0)
return vector<Point>(1, is_ll(s, t));
else {
vector<Point> ans;
for (int k = 0; k < 2; ++k) {
if (isis_sp(s, t[k]) && find(ans.begin(), ans.end(), t[k]) == ans.end())
ans.push_back(t[k]);
if (isis_sp(t, s[k]) && find(ans.begin(), ans.end(), s[k]) == ans.end())
ans.push_back(s[k]);
}
return ans;
}
}
// ????????¨???????????????
//???????????£????????¨???????????¨assert(false)
Point is_ss(const Line &s, const Line &t) {
if (isis_ss(s, t)) {
for (int k = 0; k < 2; ++k) {
for (int l = 0; l < 2; ++l) {
if (s[k] == t[l])
return s[k];
}
}
return is_ll(s, t);
} else {
//??????isis_ss?????????
assert(false);
return Point(0, 0);
}
}
// ????????¨???????????????
vector<Point> is_ss2(const Line &s, const Line &t) {
vector<Point> kouho(is_ll2(s, t));
vector<Point> ans;
for (auto p : kouho) {
if (isis_sp(s, p) && isis_sp(t, p))
ans.emplace_back(p);
}
return ans;
}
// ??´?????¨???????????¢
ld dist_lp(const Line &l, const Point &p) { return abs(p - proj(l, p)); }
//??´?????¨??´???????????¢
ld dist_ll(const Line &l, const Line &m) {
return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}
// ??´?????¨??????????????¢
ld dist_ls(const Line &l, const Line &s) {
return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}
// ????????¨???????????¢
ld dist_sp(const Line &s, const Point &p) {
Point r = proj(s, p);
return isis_sp(s, r) ? abs(r - p) : min(abs(s.a - p), abs(s.b - p));
}
// ????????¨??????????????¢
ld dist_ss(const Line &s, const Line &t) {
if (isis_ss(s, t))
return 0;
return min(
{dist_sp(s, t.a), dist_sp(s, t.b), dist_sp(t, s.a), dist_sp(t, s.b)});
}
//??´?????¨??´?????????????????????????????????
Line bisection(const Line &s, const Line &t) {
const Point laglanju(is_ll(s, t));
const Point avec =
!(abs(laglanju - s[0]) < eps) ? s[0] - laglanju : s[1] - laglanju;
const Point bvec =
!(abs(laglanju - t[0]) < eps) ? t[0] - laglanju : t[1] - laglanju;
return Line(laglanju, laglanju + (abs(bvec) * avec + abs(avec) * bvec) /
(abs(avec) + abs(bvec)));
}
//???????????´?????????????????????
//???????????´??????????????§???????????¨????¢?????????¨?????????
Point inner_center(const vector<Line> &ls) {
vector<Point> vertics;
for (int i = 0; i < static_cast<int>(ls.size()); ++i) {
vertics.push_back(is_ll(ls[i], ls[(i + 1) % 3]));
}
if (vertics[0] == vertics[1] || vertics[1] == vertics[2] ||
vertics[2] == vertics[0])
return vertics[0];
Line bi1(
bisection(Line(vertics[0], vertics[1]), Line(vertics[0], vertics[2])));
Line bi2(
bisection(Line(vertics[1], vertics[2]), Line(vertics[1], vertics[0])));
if (bi1[0] == bi2[0])
return bi1[0];
else {
return is_ll(bi1, bi2);
}
}
//???????????´?????????????????????
//???????????´??????????????§???????????¨????¢?????????¨?????????
vector<Point> ex_center(const vector<Line> &ls) {
vector<Point> vertics;
for (int i = 0; i < static_cast<int>(ls.size()); ++i) {
vertics.push_back(is_ll(ls[i], ls[(i + 1) % 3]));
}
if (abs(vertics[0] - vertics[1]) < eps ||
abs(vertics[1] - vertics[2]) < eps ||
(abs(vertics[2] - vertics[0]) < eps))
return vector<Point>();
vector<Point> ecs;
for (int i = 0; i < 3; ++i) {
Line bi1(
bisection(Line(vertics[i], vertics[i] * 2.0l - vertics[(i + 2) % 3]),
Line(vertics[i], vertics[(i + 1) % 3])));
Line bi2(bisection(Line(vertics[(i + 1) % 3],
vertics[(i + 1) % 3] * 2.0l - vertics[(i + 2) % 3]),
Line(vertics[(i + 1) % 3], vertics[i])));
ecs.push_back(is_ll(bi1, bi2));
}
return ecs;
}
// a,b:??????
// c:????????§??????
//???????????´?????????????????¢?????????????±??????????
vector<Point> same_dis(const vector<Line> &ls) {
vector<Point> vertics;
vertics.push_back(is_ll(ls[0], ls[2]));
vertics.push_back(is_ll(ls[1], ls[2]));
if (abs(vertics[0] - vertics[1]) < eps)
return vector<Point>{vertics[0]};
Line bis(bisection(ls[0], ls[1]));
vector<Point> ecs;
Line abi(bisection(Line(vertics[0], vertics[1]), ls[0]));
ecs.push_back(is_ll(bis, abi));
Line bbi(bisection(Line(vertics[0], 2.l * vertics[0] - vertics[1]), ls[0]));
ecs.push_back(is_ll(bis, bbi));
return ecs;
}
/* ??? */
// ?????¨????????????
vector<Point> is_cc(const Circle &c1, const Circle &c2) {
vector<Point> res;
ld d = abs(c1.p - c2.p);
ld rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
ld dfr = c1.r * c1.r - rc * rc;
if (abs(dfr) < eps)
dfr = 0.0;
else if (dfr < 0.0)
return res; // no intersection
ld rs = sqrt(dfr);
Point diff = (c2.p - c1.p) / d;
res.push_back(c1.p + diff * Point(rc, rs));
if (dfr != 0.0)
res.push_back(c1.p + diff * Point(rc, -rs));
return res;
}
//???????????????????????????
/* 0 => out
1 => on
2 => in*/
int is_in_Circle(const Circle &cir, const Point &p) {
ld dis = abs(cir.p - p);
if (dis > cir.r + eps)
return 0;
else if (dis < cir.r - eps)
return 2;
else
return 1;
}
//???lc??????rc??????????????????
/*0 => out
1 => on
2 => in*/
int Circle_in_Circle(const Circle &lc, const Circle &rc) {
ld dis = abs(lc.p - rc.p);
if (dis < rc.r - lc.r - eps)
return 2;
else if (dis > rc.r - lc.r + eps)
return 0;
else
return 1;
}
// ?????¨??´????????????
vector<Point> is_lc(const Circle &c, const Line &l) {
vector<Point> res;
ld d = dist_lp(l, c.p);
if (d < c.r + eps) {
ld len = (d > c.r) ? 0.0 : sqrt(c.r * c.r - d * d); // safety;
Point nor = (l.a - l.b) / abs(l.a - l.b);
res.push_back(proj(l, c.p) + len * nor);
res.push_back(proj(l, c.p) - len * nor);
}
return res;
}
// ?????¨??????????????¢
vector<Point> is_sc(const Circle &c, const Line &l) {
vector<Point> v = is_lc(c, l), res;
for (Point p : v)
if (isis_sp(l, p))
res.push_back(p);
return res;
}
// ?????¨????????\???
vector<Line> tangent_cp(const Circle &c, const Point &p) {
vector<Line> ret;
Point v = c.p - p;
ld d = abs(v);
ld l = sqrt(norm(v) - c.r * c.r);
if (isnan(l)) {
return ret;
}
Point v1 = v * Point(l / d, c.r / d);
Point v2 = v * Point(l / d, -c.r / d);
ret.push_back(Line(p, p + v1));
if (l < eps)
return ret;
ret.push_back(Line(p, p + v2));
return ret;
}
// ?????¨????????\???
vector<Line> tangent_cc(const Circle &c1, const Circle &c2) {
vector<Line> ret;
if (abs(c1.p - c2.p) - (c1.r + c2.r) > -eps) {
Point center = (c1.p * c2.r + c2.p * c1.r) / (c1.r + c2.r);
ret = tangent_cp(c1, center);
}
if (abs(c1.r - c2.r) > eps) {
Point out = (-c1.p * c2.r + c2.p * c1.r) / (c1.r - c2.r);
vector<Line> nret = tangent_cp(c1, out);
ret.insert(ret.end(), all(nret));
} else {
Point v = c2.p - c1.p;
v /= abs(v);
Point q1 = c1.p + v * Point(0, 1) * c1.r;
Point q2 = c1.p + v * Point(0, -1) * c1.r;
ret.push_back(Line(q1, q1 + v));
ret.push_back(Line(q2, q2 + v));
}
return ret;
}
//??????????????????????????¢???
ld two_Circle_area(const Circle &l, const Circle &r) {
ld dis = abs(l.p - r.p);
if (dis > l.r + r.r)
return 0;
else if (dis + r.r < l.r) {
return r.r * r.r * pi;
} else if (dis + l.r < r.r) {
return l.r * l.r * pi;
} else {
ld ans = (l.r) * (l.r) *
acos((dis * dis + l.r * l.r - r.r * r.r) / (2 * dis * l.r)) +
(r.r) * (r.r) *
acos((dis * dis + r.r * r.r - l.r * l.r) / (2 * dis * r.r)) -
sqrt(4 * dis * dis * l.r * l.r -
(dis * dis + l.r * l.r - r.r * r.r) *
(dis * dis + l.r * l.r - r.r * r.r)) /
2;
return ans;
}
}
/* ????§???¢ */
typedef vector<Point> Polygon;
// ??¢???
ld area(const Polygon &p) {
ld res = 0;
int n = p.size();
rep(j, n) res += cross(p[j], p[(j + 1) % n]);
return res / 2;
}
//????§???¢????????¢??????
bool is_counter_clockwise(const Polygon &poly) {
ld angle = 0;
int n = poly.size();
rep(i, n) {
Point a = poly[i], b = poly[(i + 1) % n], c = poly[(i + 2) % n];
angle += arg((c - b) / (b - a));
}
return angle > eps;
}
// ??????????????????
/*0 => out
1 => on
2 => in*/
int is_in_Polygon(const Polygon &poly, const Point &p) {
ld angle = 0;
int n = poly.size();
rep(i, n) {
Point a = poly[i], b = poly[(i + 1) % n];
if (isis_sp(Line(a, b), p))
return 1;
angle += arg((b - p) / (a - p));
}
return eq(angle, 0) ? 0 : 2;
}
//??????????????????2?????????
enum { out, on, in };
int convex_contains(const Polygon &P, const Point &p) {
const int n = P.size();
Point g = (P[0] + P[n / 3] + P[2 * n / 3]) / 3.0l; // inner-point
int a = 0, b = n;
while (a + 1 < b) { // invariant: c is in fan g-P[a]-P[b]
int c = (a + b) / 2;
if (cross(P[a] - g, P[c] - g) > 0) { // angle < 180 deg
if (cross(P[a] - g, p - g) > 0 && cross(P[c] - g, p - g) < 0)
b = c;
else
a = c;
} else {
if (cross(P[a] - g, p - g) < 0 && cross(P[c] - g, p - g) > 0)
a = c;
else
b = c;
}
}
b %= n;
if (cross(P[a] - p, P[b] - p) < 0)
return 0;
if (cross(P[a] - p, P[b] - p) > 0)
return 2;
return 1;
}
// ??????
//???????????????????????¨????????????????????§??¨???
Polygon convex_hull(vector<Point> ps) {
int n = ps.size();
int k = 0;
sort(ps.begin(), ps.end());
Polygon ch(2 * n);
for (int i = 0; i < n; ch[k++] = ps[i++])
while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
--k;
for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--])
while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
--k;
ch.resize(k - 1);
return ch;
}
//????????????
vector<Polygon> convex_cut(const Polygon &ps, const Line &l) {
int n = ps.size();
Polygon q;
Polygon r;
rep(i, n) {
Point a = ps[i], b = ps[(i + 1) % n];
Line m = Line(a, b);
if (ccw(l.a, l.b, a) != -1)
q.push_back(a);
if (ccw(l.a, l.b, a) != 1)
r.push_back(a);
if (ccw(l.a, l.b, a) * ccw(l.a, l.b, b) < 0 && isis_ll(l, m)) {
q.push_back(is_ll(l, m));
r.push_back(is_ll(l, m));
}
}
const vector<Polygon> polys{q, r};
return polys;
}
/* ??¢??¬??????????????? */
void add_Point(vector<Point> &ps, const Point p) {
for (Point q : ps)
if (abs(q - p) < eps)
return;
ps.push_back(p);
}
typedef int Weight;
struct edge {
int src, dst;
Weight weight;
edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};
typedef vector<edge> edges;
typedef vector<edges> graph;
void add_edge(graph &g, const int from, const int to, const Weight &weight) {
g[from].push_back(edge{from, to, weight});
}
graph segment_arrangement(const vector<Line> &s, const vector<Point> &p) {
int n = p.size(), m = s.size();
graph g(n);
rep(i, m) {
vector<pair<ld, int>> vec;
rep(j, n) if (isis_sp(s[i], p[j])) vec.emplace_back(abs(s[i].a - p[j]), j);
sort(all(vec));
rep(j, vec.size() - 1) {
int from = vec[j].second, to = vec[j + 1].second;
add_edge(g, from, to, static_cast<Weight>(abs(p[from] - p[to])));
}
}
return g;
}
graph sennbunn_arrangement(const vector<Line> &s) {
vector<Point> crss;
for (int i = 0; i < static_cast<int>(s.size()); ++i) {
for (int j = i + 1; j < static_cast<int>(s.size()); ++j) {
if (isis_ss(s[i], s[j])) {
crss.push_back(is_ll2(s[i], s[j])[0]);
}
}
}
for (int i = 0; i < static_cast<int>(s.size()); ++i) {
crss.push_back(s[i][0]);
crss.push_back(s[i][1]);
}
return segment_arrangement(s, crss);
}
graph Circle_arrangement(const vector<Circle> &c, const vector<Point> &p) {
int n = p.size(), m = c.size();
graph g(n);
rep(i, m) {
vector<pair<ld, int>> vec;
rep(j, n) if (abs(abs(c[i].p - p[j]) - c[i].r) < eps)
vec.emplace_back(arg(c[i].p - p[j]), j);
sort(all(vec));
rep(j, vec.size() - 1) {
int from = vec[j].second, to = vec[j + 1].second;
ld angle = vec[j + 1].first - vec[j].first;
add_edge(g, from, to, static_cast<Weight>(angle * c[i].r));
}
if (vec.size() >= 2) {
int from = vec.back().second, to = vec.front().first;
ld angle = vec.front().first - vec.back().first;
add_edge(g, from, to, static_cast<Weight>(angle * c[i].r));
}
}
return g;
}
int main() {
while (1) {
long long int num;
cin >> num;
if (num == -1)
break;
ld x = num / 2;
while (abs(x * x * x - num) > 0.00001 * num) {
x = x - (x * x * x - num) / (3 * x * x);
}
cout << setprecision(8) << fixed << x << endl;
}
return 0;
}
|
#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T> using Table = vector<vector<T>>;
const ld eps = 1e-9;
// < "D:\D_Download\Visual Studio
// 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual
// Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
/* ??????????????¬ */
#include <complex>
typedef complex<ld> Point;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ld pi = acos(-1.0);
const ld dtop = pi / 180.;
const ld ptod = 1. / dtop;
namespace std {
bool operator<(const Point &lhs, const Point &rhs) {
if (lhs.real() < rhs.real() - eps)
return true;
if (lhs.real() > rhs.real() + eps)
return false;
return lhs.imag() < rhs.imag();
}
} // namespace std
// ????????\???
Point input_Point() {
ld x, y;
cin >> x >> y;
return Point(x, y);
}
// ????????????????????????
bool eq(const ld a, const ld b) { return (abs(a - b) < eps); }
// ??????
ld dot(const Point &a, const Point &b) { return real(conj(a) * b); }
// ??????
ld cross(const Point &a, const Point &b) { return imag(conj(a) * b); }
// ??´????????????
class Line {
public:
Point a, b;
Line() : a(Point(0, 0)), b(Point(0, 0)) {}
Line(Point a, Point b) : a(a), b(b) {}
Point operator[](const int _num) const {
if (_num == 0)
return a;
else if (_num == 1)
return b;
else {
assert(false);
return Point();
}
}
};
// ????????????
class Circle {
public:
Point p;
ld r;
Circle() : p(Point(0, 0)), r(0) {}
Circle(Point p, ld r) : p(p), r(r) {}
};
// ccw
// 1: a,b,c??????????¨???¨?????????????????¶
//-1: a,b,c???????¨???¨?????????????????¶
// 2: c,a,b???????????´???????????¶
//-2: a,b,c???????????´???????????¶
// 0: a,c,b???????????´???????????¶
int ccw(const Point &a, const Point &b, const Point &c) {
const Point nb(b - a);
const Point nc(c - a);
if (cross(nb, nc) > eps)
return 1; // a,b,c??????????¨???¨?????????????????¶
if (cross(nb, nc) < -eps)
return -1; // a,b,c???????¨???¨?????????????????¶
if (dot(nb, nc) < 0)
return 2; // c,a,b???????????´???????????¶
if (norm(nb) < norm(nc))
return -2; // a,b,c???????????´???????????¶
return 0; // a,c,b???????????´???????????¶
}
/* ???????????? */
// ??´?????¨??´??????????????????
bool isis_ll(const Line &l, const Line &m) {
return !eq(cross(l.b - l.a, m.b - m.a), 0);
}
// ??´?????¨?????????????????????
bool isis_ls(const Line &l, const Line &s) {
return isis_ll(l, s) &&
(cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}
// ????????¨?????????????????????
bool isis_ss(const Line &s, const Line &t) {
return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}
// ????????´????????????
bool isis_lp(const Line &l, const Point &p) {
return (abs(cross(l.b - p, l.a - p)) < eps);
}
// ?????????????????????
bool isis_sp(const Line &s, const Point &p) {
return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}
// ??????????¶?
Point proj(const Line &l, const Point &p) {
ld t = dot(p - l.a, l.b - l.a) / norm(l.a - l.b);
return l.a + t * (l.b - l.a);
}
//???????±??????????????????????
Point reflect(const Line &l, const Point &p) {
Point pr = proj(l, p);
return pr * 2.l - p;
}
// ??´?????¨??´????????????
Point is_ll(const Line &s, const Line &t) {
Point sv = s.b - s.a, tv = t.b - t.a;
assert(cross(sv, tv) != 0);
return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}
// ??´?????¨??´????????????
vector<Point> is_ll2(const Line &s, const Line &t) {
Point sv = s.b - s.a, tv = t.b - t.a;
if (cross(sv, tv) != 0)
return vector<Point>(1, is_ll(s, t));
else {
vector<Point> ans;
for (int k = 0; k < 2; ++k) {
if (isis_sp(s, t[k]) && find(ans.begin(), ans.end(), t[k]) == ans.end())
ans.push_back(t[k]);
if (isis_sp(t, s[k]) && find(ans.begin(), ans.end(), s[k]) == ans.end())
ans.push_back(s[k]);
}
return ans;
}
}
// ????????¨???????????????
//???????????£????????¨???????????¨assert(false)
Point is_ss(const Line &s, const Line &t) {
if (isis_ss(s, t)) {
for (int k = 0; k < 2; ++k) {
for (int l = 0; l < 2; ++l) {
if (s[k] == t[l])
return s[k];
}
}
return is_ll(s, t);
} else {
//??????isis_ss?????????
assert(false);
return Point(0, 0);
}
}
// ????????¨???????????????
vector<Point> is_ss2(const Line &s, const Line &t) {
vector<Point> kouho(is_ll2(s, t));
vector<Point> ans;
for (auto p : kouho) {
if (isis_sp(s, p) && isis_sp(t, p))
ans.emplace_back(p);
}
return ans;
}
// ??´?????¨???????????¢
ld dist_lp(const Line &l, const Point &p) { return abs(p - proj(l, p)); }
//??´?????¨??´???????????¢
ld dist_ll(const Line &l, const Line &m) {
return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}
// ??´?????¨??????????????¢
ld dist_ls(const Line &l, const Line &s) {
return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}
// ????????¨???????????¢
ld dist_sp(const Line &s, const Point &p) {
Point r = proj(s, p);
return isis_sp(s, r) ? abs(r - p) : min(abs(s.a - p), abs(s.b - p));
}
// ????????¨??????????????¢
ld dist_ss(const Line &s, const Line &t) {
if (isis_ss(s, t))
return 0;
return min(
{dist_sp(s, t.a), dist_sp(s, t.b), dist_sp(t, s.a), dist_sp(t, s.b)});
}
//??´?????¨??´?????????????????????????????????
Line bisection(const Line &s, const Line &t) {
const Point laglanju(is_ll(s, t));
const Point avec =
!(abs(laglanju - s[0]) < eps) ? s[0] - laglanju : s[1] - laglanju;
const Point bvec =
!(abs(laglanju - t[0]) < eps) ? t[0] - laglanju : t[1] - laglanju;
return Line(laglanju, laglanju + (abs(bvec) * avec + abs(avec) * bvec) /
(abs(avec) + abs(bvec)));
}
//???????????´?????????????????????
//???????????´??????????????§???????????¨????¢?????????¨?????????
Point inner_center(const vector<Line> &ls) {
vector<Point> vertics;
for (int i = 0; i < static_cast<int>(ls.size()); ++i) {
vertics.push_back(is_ll(ls[i], ls[(i + 1) % 3]));
}
if (vertics[0] == vertics[1] || vertics[1] == vertics[2] ||
vertics[2] == vertics[0])
return vertics[0];
Line bi1(
bisection(Line(vertics[0], vertics[1]), Line(vertics[0], vertics[2])));
Line bi2(
bisection(Line(vertics[1], vertics[2]), Line(vertics[1], vertics[0])));
if (bi1[0] == bi2[0])
return bi1[0];
else {
return is_ll(bi1, bi2);
}
}
//???????????´?????????????????????
//???????????´??????????????§???????????¨????¢?????????¨?????????
vector<Point> ex_center(const vector<Line> &ls) {
vector<Point> vertics;
for (int i = 0; i < static_cast<int>(ls.size()); ++i) {
vertics.push_back(is_ll(ls[i], ls[(i + 1) % 3]));
}
if (abs(vertics[0] - vertics[1]) < eps ||
abs(vertics[1] - vertics[2]) < eps ||
(abs(vertics[2] - vertics[0]) < eps))
return vector<Point>();
vector<Point> ecs;
for (int i = 0; i < 3; ++i) {
Line bi1(
bisection(Line(vertics[i], vertics[i] * 2.0l - vertics[(i + 2) % 3]),
Line(vertics[i], vertics[(i + 1) % 3])));
Line bi2(bisection(Line(vertics[(i + 1) % 3],
vertics[(i + 1) % 3] * 2.0l - vertics[(i + 2) % 3]),
Line(vertics[(i + 1) % 3], vertics[i])));
ecs.push_back(is_ll(bi1, bi2));
}
return ecs;
}
// a,b:??????
// c:????????§??????
//???????????´?????????????????¢?????????????±??????????
vector<Point> same_dis(const vector<Line> &ls) {
vector<Point> vertics;
vertics.push_back(is_ll(ls[0], ls[2]));
vertics.push_back(is_ll(ls[1], ls[2]));
if (abs(vertics[0] - vertics[1]) < eps)
return vector<Point>{vertics[0]};
Line bis(bisection(ls[0], ls[1]));
vector<Point> ecs;
Line abi(bisection(Line(vertics[0], vertics[1]), ls[0]));
ecs.push_back(is_ll(bis, abi));
Line bbi(bisection(Line(vertics[0], 2.l * vertics[0] - vertics[1]), ls[0]));
ecs.push_back(is_ll(bis, bbi));
return ecs;
}
/* ??? */
// ?????¨????????????
vector<Point> is_cc(const Circle &c1, const Circle &c2) {
vector<Point> res;
ld d = abs(c1.p - c2.p);
ld rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
ld dfr = c1.r * c1.r - rc * rc;
if (abs(dfr) < eps)
dfr = 0.0;
else if (dfr < 0.0)
return res; // no intersection
ld rs = sqrt(dfr);
Point diff = (c2.p - c1.p) / d;
res.push_back(c1.p + diff * Point(rc, rs));
if (dfr != 0.0)
res.push_back(c1.p + diff * Point(rc, -rs));
return res;
}
//???????????????????????????
/* 0 => out
1 => on
2 => in*/
int is_in_Circle(const Circle &cir, const Point &p) {
ld dis = abs(cir.p - p);
if (dis > cir.r + eps)
return 0;
else if (dis < cir.r - eps)
return 2;
else
return 1;
}
//???lc??????rc??????????????????
/*0 => out
1 => on
2 => in*/
int Circle_in_Circle(const Circle &lc, const Circle &rc) {
ld dis = abs(lc.p - rc.p);
if (dis < rc.r - lc.r - eps)
return 2;
else if (dis > rc.r - lc.r + eps)
return 0;
else
return 1;
}
// ?????¨??´????????????
vector<Point> is_lc(const Circle &c, const Line &l) {
vector<Point> res;
ld d = dist_lp(l, c.p);
if (d < c.r + eps) {
ld len = (d > c.r) ? 0.0 : sqrt(c.r * c.r - d * d); // safety;
Point nor = (l.a - l.b) / abs(l.a - l.b);
res.push_back(proj(l, c.p) + len * nor);
res.push_back(proj(l, c.p) - len * nor);
}
return res;
}
// ?????¨??????????????¢
vector<Point> is_sc(const Circle &c, const Line &l) {
vector<Point> v = is_lc(c, l), res;
for (Point p : v)
if (isis_sp(l, p))
res.push_back(p);
return res;
}
// ?????¨????????\???
vector<Line> tangent_cp(const Circle &c, const Point &p) {
vector<Line> ret;
Point v = c.p - p;
ld d = abs(v);
ld l = sqrt(norm(v) - c.r * c.r);
if (isnan(l)) {
return ret;
}
Point v1 = v * Point(l / d, c.r / d);
Point v2 = v * Point(l / d, -c.r / d);
ret.push_back(Line(p, p + v1));
if (l < eps)
return ret;
ret.push_back(Line(p, p + v2));
return ret;
}
// ?????¨????????\???
vector<Line> tangent_cc(const Circle &c1, const Circle &c2) {
vector<Line> ret;
if (abs(c1.p - c2.p) - (c1.r + c2.r) > -eps) {
Point center = (c1.p * c2.r + c2.p * c1.r) / (c1.r + c2.r);
ret = tangent_cp(c1, center);
}
if (abs(c1.r - c2.r) > eps) {
Point out = (-c1.p * c2.r + c2.p * c1.r) / (c1.r - c2.r);
vector<Line> nret = tangent_cp(c1, out);
ret.insert(ret.end(), all(nret));
} else {
Point v = c2.p - c1.p;
v /= abs(v);
Point q1 = c1.p + v * Point(0, 1) * c1.r;
Point q2 = c1.p + v * Point(0, -1) * c1.r;
ret.push_back(Line(q1, q1 + v));
ret.push_back(Line(q2, q2 + v));
}
return ret;
}
//??????????????????????????¢???
ld two_Circle_area(const Circle &l, const Circle &r) {
ld dis = abs(l.p - r.p);
if (dis > l.r + r.r)
return 0;
else if (dis + r.r < l.r) {
return r.r * r.r * pi;
} else if (dis + l.r < r.r) {
return l.r * l.r * pi;
} else {
ld ans = (l.r) * (l.r) *
acos((dis * dis + l.r * l.r - r.r * r.r) / (2 * dis * l.r)) +
(r.r) * (r.r) *
acos((dis * dis + r.r * r.r - l.r * l.r) / (2 * dis * r.r)) -
sqrt(4 * dis * dis * l.r * l.r -
(dis * dis + l.r * l.r - r.r * r.r) *
(dis * dis + l.r * l.r - r.r * r.r)) /
2;
return ans;
}
}
/* ????§???¢ */
typedef vector<Point> Polygon;
// ??¢???
ld area(const Polygon &p) {
ld res = 0;
int n = p.size();
rep(j, n) res += cross(p[j], p[(j + 1) % n]);
return res / 2;
}
//????§???¢????????¢??????
bool is_counter_clockwise(const Polygon &poly) {
ld angle = 0;
int n = poly.size();
rep(i, n) {
Point a = poly[i], b = poly[(i + 1) % n], c = poly[(i + 2) % n];
angle += arg((c - b) / (b - a));
}
return angle > eps;
}
// ??????????????????
/*0 => out
1 => on
2 => in*/
int is_in_Polygon(const Polygon &poly, const Point &p) {
ld angle = 0;
int n = poly.size();
rep(i, n) {
Point a = poly[i], b = poly[(i + 1) % n];
if (isis_sp(Line(a, b), p))
return 1;
angle += arg((b - p) / (a - p));
}
return eq(angle, 0) ? 0 : 2;
}
//??????????????????2?????????
enum { out, on, in };
int convex_contains(const Polygon &P, const Point &p) {
const int n = P.size();
Point g = (P[0] + P[n / 3] + P[2 * n / 3]) / 3.0l; // inner-point
int a = 0, b = n;
while (a + 1 < b) { // invariant: c is in fan g-P[a]-P[b]
int c = (a + b) / 2;
if (cross(P[a] - g, P[c] - g) > 0) { // angle < 180 deg
if (cross(P[a] - g, p - g) > 0 && cross(P[c] - g, p - g) < 0)
b = c;
else
a = c;
} else {
if (cross(P[a] - g, p - g) < 0 && cross(P[c] - g, p - g) > 0)
a = c;
else
b = c;
}
}
b %= n;
if (cross(P[a] - p, P[b] - p) < 0)
return 0;
if (cross(P[a] - p, P[b] - p) > 0)
return 2;
return 1;
}
// ??????
//???????????????????????¨????????????????????§??¨???
Polygon convex_hull(vector<Point> ps) {
int n = ps.size();
int k = 0;
sort(ps.begin(), ps.end());
Polygon ch(2 * n);
for (int i = 0; i < n; ch[k++] = ps[i++])
while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
--k;
for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--])
while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
--k;
ch.resize(k - 1);
return ch;
}
//????????????
vector<Polygon> convex_cut(const Polygon &ps, const Line &l) {
int n = ps.size();
Polygon q;
Polygon r;
rep(i, n) {
Point a = ps[i], b = ps[(i + 1) % n];
Line m = Line(a, b);
if (ccw(l.a, l.b, a) != -1)
q.push_back(a);
if (ccw(l.a, l.b, a) != 1)
r.push_back(a);
if (ccw(l.a, l.b, a) * ccw(l.a, l.b, b) < 0 && isis_ll(l, m)) {
q.push_back(is_ll(l, m));
r.push_back(is_ll(l, m));
}
}
const vector<Polygon> polys{q, r};
return polys;
}
/* ??¢??¬??????????????? */
void add_Point(vector<Point> &ps, const Point p) {
for (Point q : ps)
if (abs(q - p) < eps)
return;
ps.push_back(p);
}
typedef int Weight;
struct edge {
int src, dst;
Weight weight;
edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};
typedef vector<edge> edges;
typedef vector<edges> graph;
void add_edge(graph &g, const int from, const int to, const Weight &weight) {
g[from].push_back(edge{from, to, weight});
}
graph segment_arrangement(const vector<Line> &s, const vector<Point> &p) {
int n = p.size(), m = s.size();
graph g(n);
rep(i, m) {
vector<pair<ld, int>> vec;
rep(j, n) if (isis_sp(s[i], p[j])) vec.emplace_back(abs(s[i].a - p[j]), j);
sort(all(vec));
rep(j, vec.size() - 1) {
int from = vec[j].second, to = vec[j + 1].second;
add_edge(g, from, to, static_cast<Weight>(abs(p[from] - p[to])));
}
}
return g;
}
graph sennbunn_arrangement(const vector<Line> &s) {
vector<Point> crss;
for (int i = 0; i < static_cast<int>(s.size()); ++i) {
for (int j = i + 1; j < static_cast<int>(s.size()); ++j) {
if (isis_ss(s[i], s[j])) {
crss.push_back(is_ll2(s[i], s[j])[0]);
}
}
}
for (int i = 0; i < static_cast<int>(s.size()); ++i) {
crss.push_back(s[i][0]);
crss.push_back(s[i][1]);
}
return segment_arrangement(s, crss);
}
graph Circle_arrangement(const vector<Circle> &c, const vector<Point> &p) {
int n = p.size(), m = c.size();
graph g(n);
rep(i, m) {
vector<pair<ld, int>> vec;
rep(j, n) if (abs(abs(c[i].p - p[j]) - c[i].r) < eps)
vec.emplace_back(arg(c[i].p - p[j]), j);
sort(all(vec));
rep(j, vec.size() - 1) {
int from = vec[j].second, to = vec[j + 1].second;
ld angle = vec[j + 1].first - vec[j].first;
add_edge(g, from, to, static_cast<Weight>(angle * c[i].r));
}
if (vec.size() >= 2) {
int from = vec.back().second, to = vec.front().first;
ld angle = vec.front().first - vec.back().first;
add_edge(g, from, to, static_cast<Weight>(angle * c[i].r));
}
}
return g;
}
int main() {
while (1) {
ld num;
cin >> num;
if (num == -1)
break;
ld x = num / 2;
while (abs(x * x * x - num) > 0.00001 * num) {
x = x - (x * x * x - num) / (3 * x * x);
}
cout << setprecision(8) << fixed << x << endl;
}
return 0;
}
|
[["-", 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 / 2;
do {
x[i] = temp(x[i], q);
} while (fabs(x[i] * x[i] * x[i] - q) >= 1e-5 * q);
}
for (int j = 0; j < i; j++) {
printf("%.6f,\n", x[j]);
}
}
|
#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] = temp(x[i], q);
} while (fabs(x[i] * x[i] * x[i] - q) >= 1e-5 * q);
}
for (int j = 0; j < i; j++) {
printf("%.6f\n", x[j]);
}
}
|
[["-", 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.0 * x * x);
}
printf("%.6lf\n", x);
}
}
|
#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);
}
printf("%.6lf\n", 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)
x -= (x * x * x - in) / (3 * x * x);
if (in != 1)
printf("%.9lf\n", x);
else
cout << 1 << endl;
}
}
|
#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 - in) / (3 * x * x);
if (in != 1)
printf("%.6f\n", x);
else
cout << 1 << endl;
}
}
|
[["-", 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, 33], ["+", 0, 52, 8, 196, 0, 1, 0, 677, 17, 110]]
| 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;
}
}
for (int i = 0; i < 8; i++) {
int thisBest = 0;
for (int j = 0; j < 8; j++) {
if (customer[j] > jenny[j + i]) {
thisBest += (customer[j] - jenny[j + i]);
}
}
if (best >= thisBest) {
bool flag = false;
if (best == thisBest) {
for (int j = 0; j < 8; j++) {
if (ans[j] < jenny[j + i]) {
flag = true;
break;
}
if (ans[j] > jenny[j + i]) {
break;
}
}
}
if (flag) {
break;
}
best = thisBest;
for (int j = 0; j < 8; j++) {
ans[j] = jenny[j + i];
}
}
}
for (int i = 0; i < 8; i++) {
cout << ans[i];
cout << ((i == 7) ? '\n' : ' ');
}
}
return 0;
}
|
#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;
}
}
for (int i = 0; i < 8; i++) {
int thisBest = 0;
for (int j = 0; j < 8; j++) {
if (customer[j] > jenny[j + i]) {
thisBest += (customer[j] - jenny[j + i]);
}
}
if (best >= thisBest) {
bool flag = false;
if (best == thisBest) {
for (int j = 0; j < 8; j++) {
if (ans[j] < jenny[j + i]) {
flag = true;
break;
}
if (ans[j] > jenny[j + i]) {
break;
}
}
}
if (flag) {
continue;
}
best = thisBest;
for (int j = 0; j < 8; j++) {
ans[j] = jenny[j + i];
}
}
}
for (int i = 0; i < 8; i++) {
cout << ans[i];
cout << ((i == 7) ? '\n' : ' ');
}
}
return 0;
}
|
[["-", 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], &p[1], &p[2], &p[3], &p[4], &p[5],
&p[6], &p[7])) {
int ret = 999999999;
for (int i = 0; i < 8; i++)
t[i] = 5;
for (int i = 0; i < 8; i++) {
int res = 0;
for (int j = i; j < i + 8; j++)
res += max(p[j - i] - c[j % 8], 0), u[j - i] = c[j % 8];
if (res < ret) {
ret = res;
for (int j = 0; j < 8; j++)
t[j] = u[j];
} else if (res == ret && comp()) {
for (int j = 0; j < 8; j++)
t[j] = u[j];
}
}
for (int j = 0; j < 8; j++) {
printf(j ? "%d " : "%d", t[j]);
}
printf("\n");
}
return 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], &p[1], &p[2], &p[3], &p[4], &p[5],
&p[6], &p[7])) {
int ret = 999999999;
for (int i = 0; i < 8; i++)
t[i] = 5;
for (int i = 0; i < 8; i++) {
int res = 0;
for (int j = i; j < i + 8; j++)
res += max(p[j - i] - c[j % 8], 0), u[j - i] = c[j % 8];
if (res < ret) {
ret = res;
for (int j = 0; j < 8; j++)
t[j] = u[j];
} else if (res == ret && comp()) {
for (int j = 0; j < 8; j++)
t[j] = u[j];
}
}
for (int j = 0; j < 8; j++)
printf(j ? " %d" : "%d", t[j]);
printf("\n");
}
return 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;
Pair ans(INF, INF);
for (int i = 0; i < 8; i++) {
int sum = 0;
int encoded = 0;
for (int j = 0; j < 8; j++) {
sum += max(ps[j] - d[(i + j) % 8], 0);
encoded = encoded * 10 + d[(i + j) % 8];
}
ans = min(ans, Pair(sum, encoded));
mod *= 10;
}
int t = ans.second;
mod /= 10;
printf("%d", t / mod);
t %= mod;
for (int i = 1; i < 8; i++) {
mod /= 10;
printf(" %d", t / mod);
t %= mod;
}
}
}
|
/* 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;
}
int mod = 1;
Pair ans(INF, INF);
for (int i = 0; i < 8; i++) {
int sum = 0;
int encoded = 0;
for (int j = 0; j < 8; j++) {
sum += max(ps[j] - d[(i + j) % 8], 0);
encoded = encoded * 10 + d[(i + j) % 8];
}
ans = min(ans, Pair(sum, encoded));
mod *= 10;
}
int t = ans.second;
mod /= 10;
printf("%d", t / mod);
t %= mod;
for (int i = 1; i < 8; i++) {
mod /= 10;
printf(" %d", t / mod);
t %= mod;
}
puts("");
}
}
|
[["+", 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];
int minWaiting = INT_MAX;
int minWaitingIndex = 0;
for (int j = 0; j < 8; j++) {
int headIndex = index[j];
int numOfWaiting = 0;
for (int i = 0; i < 8; i++) {
numOfWaiting += max(p[i] - capacity[(headIndex + i) % 8], 0);
}
if (minWaiting > numOfWaiting) {
minWaiting = numOfWaiting;
minWaitingIndex = headIndex;
}
}
for (int i = 0; i < 7; i++) {
cout << capacity[(minWaitingIndex + i) % 8] << " ";
}
cout << capacity[(minWaitingIndex + 7) % 8] << endl;
}
return 0;
}
|
#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];
int minWaiting = INT_MAX;
int minWaitingIndex = 0;
for (int j = 0; j < 8; j++) {
int headIndex = index[j];
int numOfWaiting = 0;
for (int i = 0; i < 8; i++) {
numOfWaiting += max(p[i] - capacity[(headIndex + i) % 8], 0);
}
if (minWaiting > numOfWaiting) {
minWaiting = numOfWaiting;
minWaitingIndex = headIndex;
}
}
for (int i = 0; i < 7; i++) {
cout << capacity[(minWaitingIndex + i) % 8] << " ";
}
cout << capacity[(minWaitingIndex + 7) % 8] << endl;
}
return 0;
}
|
[["-", 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; i++) {
wait = 0;
for (j = 0; j < N; j++) {
if (passenger[j] - vehicle[(j + i) % N] > 0)
wait += passenger[j] - vehicle[(j + i) % N];
}
if (min > wait) {
min = wait;
place = i;
} else if (min == wait) {
int t = 0, d = 1;
for (j = N - 1; j >= 0; j--) {
t += vehicle[(j + i) % N] * d - vehicle[(j + place) % N];
d *= 10;
}
if (t < 0)
place = i;
}
}
for (i = 0; i < N; i++) {
if (i != 0)
cout << ' ';
cout << vehicle[(i + place) % N];
}
cout << endl;
}
}
|
#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; i++) {
wait = 0;
for (j = 0; j < N; j++) {
if (passenger[j] - vehicle[(j + i) % N] > 0)
wait += passenger[j] - vehicle[(j + i) % N];
}
if (min > wait) {
min = wait;
place = i;
} else if (min == wait) {
int t = 0, d = 1;
for (j = N - 1; j >= 0; j--) {
t += vehicle[(j + i) % N] * d - vehicle[(j + place) % N] * d;
d *= 10;
}
if (t < 0)
place = i;
}
}
for (i = 0; i < N; i++) {
if (i != 0)
cout << ' ';
cout << vehicle[(i + place) % N];
}
cout << endl;
}
}
|
[["+", 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[i])) return 0;
rep(i, 8) {
rep(j, 8) { r[i] += max(0, w[j] - c[j]); }
m = min(m, r[i]);
rep(j, 7) swap(c[j], c[j - 1]);
}
rep(i, 8) {
if (r[dict[i]] == m) {
rep(j, 8) {
cout << c[(dict[i] + j) % 8];
if (j != 7)
cout << " ";
}
cout << endl;
break;
}
}
}
return 0;
}
|
#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[i])) return 0;
rep(i, 8) {
rep(j, 8) { r[i] += max(0, w[j] - c[j]); }
m = min(m, r[i]);
rep(j, 7) swap(c[j], c[j + 1]);
}
rep(i, 8) {
if (r[dict[i]] == m) {
rep(j, 8) {
cout << c[(dict[i] + j) % 8];
if (j != 7)
cout << " ";
}
cout << endl;
break;
}
}
}
return 0;
}
|
[["-", 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.14159265359;
typedef complex<double> P;
const int k[8] = {0, 2, 6, 4, 1, 3, 7, 5};
const int c[8] = {1, 2, 1, 2, 1, 4, 1, 4};
int rest(int *p, int i) {
int v = 0;
for (int j = 0; j < 8; j++) {
int r = p[j] - c[(j + k[i]) % 8];
if (r > 0) {
v += r;
}
}
return v;
}
int main() {
int p[8];
while (cin >> p[0]) {
for (int i = 1; i < 8; i++) {
cin >> p[i];
}
int m = rest(p, 0);
int im = 0;
for (int i = 1; i < 8; i++) {
if (m > rest(p, i)) {
m = rest(p, i);
im = i;
}
}
bool f = true;
for (int i = 0; i < 8; i++) {
if (!f) {
cout << ' ';
}
f = true;
cout << c[(i + k[im]) % 8];
}
cout << endl;
}
return 0;
}
|
#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.14159265359;
typedef complex<double> P;
const int k[8] = {0, 2, 6, 4, 1, 3, 7, 5};
const int c[8] = {1, 2, 1, 2, 1, 4, 1, 4};
int rest(int *p, int i) {
int v = 0;
for (int j = 0; j < 8; j++) {
int r = p[j] - c[(j + k[i]) % 8];
if (r > 0) {
v += r;
}
}
return v;
}
int main() {
int p[8];
while (cin >> p[0]) {
for (int i = 1; i < 8; i++) {
cin >> p[i];
}
int m = rest(p, 0);
int im = 0;
for (int i = 1; i < 8; i++) {
if (m > rest(p, i)) {
m = rest(p, i);
im = i;
}
}
bool f = true;
for (int i = 0; i < 8; i++) {
if (!f) {
cout << ' ';
}
f = false;
cout << c[(i + k[im]) % 8];
}
cout << endl;
}
return 0;
}
|
[["-", 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;
t = 0;
for (i = 0; i < 8; i++) {
s = 0;
for (j = 0, k = o[i]; j < 8; j++, k++, k %= 8) {
s += min(l[j], m[k]);
}
if (s >= t) {
t = s;
u = i;
}
}
printf("%d", m[o[u]]);
for (i = 1, j = (o[u] + 1) % 8; i < 8; i++, j++, j %= 8) {
printf(" %d", m[j]);
}
printf("\n");
}
return 0;
}
|
#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;
t = 0;
for (i = 0; i < 8; i++) {
s = 0;
for (j = 0, k = o[i]; j < 8; j++, k++, k %= 8) {
s += min(l[j], m[k]);
}
if (s >= t) {
t = s;
u = i;
}
}
printf("%d", m[o[u]]);
for (i = 1, j = (o[u] + 1) % 8; i < 8; i++, j++, j %= 8) {
printf(" %d", m[j]);
}
printf("\n");
}
return 0;
}
|
[["-", 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 <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;
const int INF = 1 << 30;
int pow(int a, int b) {
if (b == 0)
return 1;
return a * pow(a, b - 1);
}
int tonum(int *n) {
int ret = 0;
for (int i = 1; i <= 8; i++) {
ret += n[8 - i] * pow(10, i);
}
return ret;
}
int main() {
int F[8][8], T[8];
int L[] = {1, 4, 1, 4, 1, 2, 1, 2};
for (int i = 0; i < 8; i++) {
F[0][i] = L[i];
}
for (int i = 1; i < 8; i++) {
for (int j = 0, k = i; j < 8; j++, k++) {
if (k > 7) {
k = 0;
}
F[i][k] = F[0][j];
}
}
while (cin >> T[0]) {
int res, sum = INF;
for (int i = 1; i < 8; i++) {
cin >> T[i];
}
for (int i = 0; i < 8; i++) {
int s = 0;
for (int j = 0; j < 8; j++) {
if (T[j] - F[i][j] > 0) {
s += T[j] - F[i][j];
}
}
if (sum > s || s == sum && tonum(F[res]) > tonum(F[i])) {
res = i;
sum = s;
}
}
for (int i = 0; i < 8; i++) {
printf("%d%s", F[res][i], (i != 7) ? " " : "");
}
}
}
|
#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;
const int INF = 1 << 30;
int pow(int a, int b) {
if (b == 0)
return 1;
return a * pow(a, b - 1);
}
int tonum(int *n) {
int ret = 0;
for (int i = 1; i <= 8; i++) {
ret += n[8 - i] * pow(10, i);
}
return ret;
}
int main() {
int F[8][8], T[8];
int L[] = {1, 4, 1, 4, 1, 2, 1, 2};
for (int i = 0; i < 8; i++) {
F[0][i] = L[i];
}
for (int i = 1; i < 8; i++) {
for (int j = 0, k = i; j < 8; j++, k++) {
if (k > 7) {
k = 0;
}
F[i][k] = F[0][j];
}
}
while (cin >> T[0]) {
int res, sum = INF;
for (int i = 1; i < 8; i++) {
cin >> T[i];
}
for (int i = 0; i < 8; i++) {
int s = 0;
for (int j = 0; j < 8; j++) {
if (T[j] - F[i][j] > 0) {
s += T[j] - F[i][j];
}
}
if (sum > s || s == sum && tonum(F[res]) > tonum(F[i])) {
res = i;
sum = s;
}
}
for (int i = 0; i <= 7; i++) {
printf("%d%s", F[res][i], (i != 7) ? " " : "\n");
}
}
}
|
[["-", 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, mery.end());
int t = 0;
for (int j = 0; j < 8; j++) {
if ((mery[j] - '0') < k[j])
t += k[j] - (mery[j] - '0');
}
if (mn >= t) {
if (mn == t && mnum > atoi(mery.c_str())) {
mnum = atoi(mery.c_str());
mn = t;
ans = mery;
} else {
mnum = atoi(mery.c_str());
mn = t;
ans = mery;
}
}
}
for (int i = 0; i < 8; i++) {
if (i == 0)
cout << ans[i];
else
cout << " " << ans[i];
}
cout << endl;
}
return 0;
}
|
#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, mery.end());
int t = 0;
for (int j = 0; j < 8; j++) {
if ((mery[j] - '0') < k[j])
t += k[j] - (mery[j] - '0');
}
if (mn >= t) {
if (mn == t && mnum > atoi(mery.c_str())) {
mnum = atoi(mery.c_str());
mn = t;
ans = mery;
} else if (mn > t) {
mnum = atoi(mery.c_str());
mn = t;
ans = mery;
}
}
}
for (int i = 0; i < 8; i++) {
if (i == 0)
cout << ans[i];
else
cout << " " << ans[i];
}
cout << endl;
}
return 0;
}
|
[["+", 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];
for (; cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7];) {
int data[] = {4, 1, 4, 1, 2, 1, 2, 1};
int anscnt = check(p, data);
int ans[8];
for (int i = 0; i < 8; i++)
ans[i] = data[i];
int buf = makeint(p);
for (int i = 0; i < 7; i++) {
int tt = data[0];
for (int i = 0; i < 7; i++)
data[i] = data[i + 1];
data[7] = tt;
int tmp = check(p, data);
int tbuf = makeint(p);
if (tmp < anscnt || (tmp == anscnt && tbuf < buf)) {
anscnt = tmp;
buf = tbuf;
for (int i = 0; i < 8; i++)
ans[i] = data[i];
}
}
for (int i = 0; i < 8; i++) {
cout << ans[i];
if (i == 7)
cout << endl;
else
cout << " ";
}
}
}
|
#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];
for (; cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7];) {
int data[] = {4, 1, 4, 1, 2, 1, 2, 1};
int anscnt = check(p, data);
int ans[8];
for (int i = 0; i < 8; i++)
ans[i] = data[i];
int buf = makeint(data);
for (int i = 0; i < 7; i++) {
int tt = data[0];
for (int i = 0; i < 7; i++)
data[i] = data[i + 1];
data[7] = tt;
int tmp = check(p, data);
int tbuf = makeint(data);
if (tmp < anscnt || (tmp == anscnt && tbuf < buf)) {
anscnt = tmp;
buf = tbuf;
for (int i = 0; i < 8; i++)
ans[i] = data[i];
}
}
for (int i = 0; i < 8; i++) {
cout << ans[i];
if (i == 7)
cout << endl;
else
cout << " ";
}
}
}
|
[["-", 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, 1, 4},
};
int ians, sans, sum;
while (cin >> pdata[0]) {
for (int i = 1; i < 8; i++) {
cin >> pdata[i];
}
for (int i = 7; i >= 0; i--) {
sum = 0;
for (int j = 0; j < 8; j++) {
if (pdata[j] > cdata[i][j])
sum += pdata[j] - cdata[i][j];
}
if (i == 7) {
ians = 0;
sans = sum;
} else if (sum < sans) {
ians = i;
sans = sum;
}
}
for (int i = 0; i < 7; i++) {
cout << cdata[ians][i] << " ";
}
cout << cdata[ians][7] << endl;
}
return 0;
}
|
#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, 1, 4},
};
int ians, sans, sum;
while (cin >> pdata[0]) {
for (int i = 1; i < 8; i++) {
cin >> pdata[i];
}
for (int i = 7; i >= 0; i--) {
sum = 0;
for (int j = 0; j < 8; j++) {
if (pdata[j] > cdata[i][j])
sum += pdata[j] - cdata[i][j];
}
if (i == 7) {
ians = 7;
sans = sum;
} else if (sum < sans) {
ians = i;
sans = sum;
}
}
for (int i = 0; i < 7; i++) {
cout << cdata[ians][i] << " ";
}
cout << cdata[ians][7] << endl;
}
return 0;
}
|
[["-", 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 += x[i];
}
for (i = 7; i--;) {
s = 0;
for (j = 7; j--;) {
tmp = x[j] - B[i + j] + '0';
s += (tmp > 0 ? tmp : 0);
}
if (s < m) {
m = s;
p = i;
} else if (m == s && C[i] < C[p])
p = i;
}
for (i = 0; i < 8; i++)
std::cout << B[p + i] << " \n"[i == 7];
}
}
|
#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 += x[i];
}
for (i = 8; i--;) {
s = 0;
for (j = 8; j--;) {
tmp = x[j] - B[i + j] + '0';
s += (tmp > 0 ? tmp : 0);
}
if (s < m) {
m = s;
p = i;
} else if (m == s && C[i] < C[p])
p = i;
}
for (i = 0; i < 8; i++)
std::cout << B[p + i] << " \n"[i == 7];
}
}
|
[["-", 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
return false
end
while true
line = gets
break if line == nil
that = line.chomp.split.map{|x| x.to_i}
mx = -1
res = []
for i in 0...10
it.rotate!
m = dif(it, that)
if (m > mx) or ((m == mx) and (less res, it))
mx = m
res = it.clone
end
end
puts res.join(' ')
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
return false
end
while true
line = gets
break if line == nil
that = line.chomp.split.map{|x| x.to_i}
mx = -1
res = []
for i in 0...10
it.rotate!
m = dif(it, that)
if (m > mx) or ((m == mx) and (less it, res))
mx = m
res = it.clone
end
end
puts res.join(' ')
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):
#乗車不能人数
num = sum([max(0, plst[j] - horse[j]) for j in range(8)])
#人数が最小値と等しく、並びの数値が小さければ更新
if num == min_num and min_horse > horse:
min_hose = horse[:]
#人数が最小値より小さければ更新
elif num < min_num:
min_num = num
min_horse = horse[:]
#馬を回転
horse.append(horse.pop(0))
print(" ".join(map(str, min_horse)))
except EOFError:
break
|
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):
#乗車不能人数
num = sum([max(0, plst[j] - horse[j]) for j in range(8)])
#人数が最小値と等しく、並びの数値が小さければ更新
if num == min_num and comp(min_horse, horse):
min_horse = horse[:]
#人数が最小値より小さければ更新
elif num < min_num:
min_num = num
min_horse = horse[:]
#馬を回転
horse.append(horse.pop(0))
print(" ".join(map(str, min_horse)))
except EOFError:
break
|
[["+", 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_horse > horse:
max_hose = horse[:]
#人数が最大値より大きければ更新
elif num > max_num:
max_num = num
max_horse = horse[:]
#馬を回転
horse.append(horse.pop(0))
print(" ".join(map(str, max_horse)))
except EOFError:
break
|
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_horse > horse:
max_horse = horse[:]
#人数が最大値より大きければ更新
elif num > max_num:
max_num = num
max_horse = horse[:]
#馬を回転
horse.append(horse.pop(0))
print(" ".join(map(str, max_horse)))
except EOFError:
break
|
[["-", 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:
ac = "".join(map(str, c[sp:]+c[:sp]))
if int(mxc) > int(ac):
mxc = ac
print(" ".join(map(str, mxcart)))
except:
break
|
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:
ac = "".join(map(str, c[sp:]+c[:sp]))
if int(mxc) > int(ac):
mxc = ac
print(" ".join(map(str, mxc)))
except:
break
|
[["-", 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();
Calendar calendar = Calendar.getInstance();
calendar.set(year, month - 1, date);
Calendar heisei = Calendar.getInstance();
heisei.set(1989, 0, 8);
Calendar showa = Calendar.getInstance();
showa.set(1926, 11, 25);
Calendar taisho = Calendar.getInstance();
taisho.set(1912, 6, 30);
Calendar meiji = Calendar.getInstance();
meiji.set(1868, 8, 8);
if (calendar.compareTo(heisei) >= 0) {
System.out.println(String.format("heisei %d %d %d",
year - heisei.get(Calendar.YEAR) + 1,
month, date));
} else if (calendar.compareTo(showa) >= 0) {
System.out.println(String.format("showa %d %d %d",
year - showa.get(Calendar.YEAR) + 1,
month, date));
} else if (calendar.compareTo(taisho) >= 0) {
System.out.println(String.format("taisyo %d %d %d",
year - taisho.get(Calendar.YEAR) + 1,
month, date));
} else if (calendar.compareTo(meiji) >= 0) {
System.out.println(String.format("meiji %d %d %d",
year - meiji.get(Calendar.YEAR) + 1,
month, date));
} else {
System.out.println("pre-meiji");
}
}
}
}
|
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();
Calendar calendar = Calendar.getInstance();
calendar.set(year, month - 1, date);
Calendar heisei = Calendar.getInstance();
heisei.set(1989, 0, 8);
Calendar showa = Calendar.getInstance();
showa.set(1926, 11, 25);
Calendar taisho = Calendar.getInstance();
taisho.set(1912, 6, 30);
Calendar meiji = Calendar.getInstance();
meiji.set(1868, 8, 8);
if (calendar.compareTo(heisei) >= 0) {
System.out.println(String.format("heisei %d %d %d",
year - heisei.get(Calendar.YEAR) + 1,
month, date));
} else if (calendar.compareTo(showa) >= 0) {
System.out.println(String.format("showa %d %d %d",
year - showa.get(Calendar.YEAR) + 1,
month, date));
} else if (calendar.compareTo(taisho) >= 0) {
System.out.println(String.format("taisho %d %d %d",
year - taisho.get(Calendar.YEAR) + 1,
month, date));
} else if (calendar.compareTo(meiji) >= 0) {
System.out.println(String.format("meiji %d %d %d",
year - meiji.get(Calendar.YEAR) + 1,
month, date));
} else {
System.out.println("pre-meiji");
}
}
}
}
|
[["-", 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.err.println(deepToString(os)); }
Scanner sc = new Scanner(System.in);
public void run() {
for (; sc.hasNext();) {
int y = sc.nextInt();
int m = sc.nextInt();
int d = sc.nextInt();
final int premeiji = 0;
final int meiji = 1;
final int taisho = 2;
final int showa = 3;
final int heisei = 4;
int res = -1;
if (y < 1868 || (y == 1868 && m < 9) || (y == 1868 && m == 9 && d < 8)) {
res = premeiji;
} else if (y < 1912 || (y == 1912 && m < 7) ||
(y == 1912 && m == 7 && d < 30)) {
res = meiji;
} else if (y < 1926 || (y == 1926 && m < 12) ||
(y == 1926 && m == 12 && d < 25)) {
res = taisho;
} else if (y < 1 || (y == 1989 && m < 1) ||
(y == 1989 && m == 1 && d < 8)) {
res = showa;
} else {
res = heisei;
}
if (res == premeiji) {
System.out.println("pre-meiji");
} else {
int yy = 0;
String nengou = "";
if (res == meiji) {
nengou = "meiji";
yy = y - 1868 + 1;
}
if (res == taisho) {
nengou = "taisho";
yy = y - 1912 + 1;
}
if (res == showa) {
nengou = "showa";
yy = y - 1926 + 1;
}
if (res == heisei) {
nengou = "heisei";
yy = y - 1989 + 1;
}
System.out.printf("%s %d %d %d\n", nengou, yy, m, d);
}
}
}
boolean premeiji(int y, int m, int d) {
if (y < 1868)
return true;
if (y >= 1869)
return false;
if (m < 9)
return true;
if (m >= 10)
return false;
if (d < 8)
return true;
return false;
}
}
|
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.err.println(deepToString(os)); }
Scanner sc = new Scanner(System.in);
public void run() {
for (; sc.hasNext();) {
int y = sc.nextInt();
int m = sc.nextInt();
int d = sc.nextInt();
final int premeiji = 0;
final int meiji = 1;
final int taisho = 2;
final int showa = 3;
final int heisei = 4;
int res = -1;
if (y < 1868 || (y == 1868 && m < 9) || (y == 1868 && m == 9 && d < 8)) {
res = premeiji;
} else if (y < 1912 || (y == 1912 && m < 7) ||
(y == 1912 && m == 7 && d < 30)) {
res = meiji;
} else if (y < 1926 || (y == 1926 && m < 12) ||
(y == 1926 && m == 12 && d < 25)) {
res = taisho;
} else if (y < 1989 || (y == 1989 && m < 1) ||
(y == 1989 && m == 1 && d < 8)) {
res = showa;
} else {
res = heisei;
}
if (res == premeiji) {
System.out.println("pre-meiji");
} else {
int yy = 0;
String nengou = "";
if (res == meiji) {
nengou = "meiji";
yy = y - 1868 + 1;
}
if (res == taisho) {
nengou = "taisho";
yy = y - 1912 + 1;
}
if (res == showa) {
nengou = "showa";
yy = y - 1926 + 1;
}
if (res == heisei) {
nengou = "heisei";
yy = y - 1989 + 1;
}
System.out.printf("%s %d %d %d\n", nengou, yy, m, d);
}
}
}
boolean premeiji(int y, int m, int d) {
if (y < 1868)
return true;
if (y >= 1869)
return false;
if (m < 9)
return true;
if (m >= 10)
return false;
if (d < 8)
return true;
return false;
}
}
|
[["-", 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 (meiji <= temp && temp < taisho)
return "meiji " + String.valueOf(y - 1868) + " " + m + " " + d;
else if (taisho <= temp && temp < showa)
return "taisho " + String.valueOf(y - 1912) + " " + m + " " + d;
else if (showa <= temp && temp < heisei)
return "show " + String.valueOf(y - 1926) + " " + m + " " + d;
else if (temp >= heisei)
return "heisei " + String.valueOf(y - 1989) + " " + m + " " + d;
else
return "pre-meiji";
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int y = sc.nextInt(), m = sc.nextInt(), d = sc.nextInt();
System.out.println(ans(era(y, m, d), y, m, d));
}
}
}
|
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 (meiji <= temp && temp < taisho)
return "meiji " + String.valueOf(y - 1868) + " " + m + " " + d;
else if (taisho <= temp && temp < showa)
return "taisho " + String.valueOf(y - 1912) + " " + m + " " + d;
else if (showa <= temp && temp < heisei)
return "showa " + String.valueOf(y - 1926) + " " + m + " " + d;
else if (temp >= heisei)
return "heisei " + String.valueOf(y - 1989) + " " + m + " " + d;
else
return "pre-meiji";
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int y = sc.nextInt(), m = sc.nextInt(), d = sc.nextInt();
System.out.println(ans(era(y, m, d), y, m, d));
}
}
}
|
[["-", 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.println("pre-meiji");
} else if (1869 <= year && year <= 1911) {
System.out.println("meiji " + (year - 1867) + " " + month + " " + day);
} else if (1913 <= year && year <= 1925) {
System.out.println("taisho " + (year - 1911) + " " + month + " " + day);
} else if (1927 <= year && year <= 1988) {
System.out.println("showa " + (year - 1925) + " " + month + " " + day);
} else if (1990 <= year) {
System.out.println("meiji " + (year - 1988) + " " + month + " " + day);
}
else if (year == 1868) {
if (month > 9) {
System.out.println("meiji 1 " + month + " " + day);
} else if (month == 9) {
if (day >= 8) {
System.out.println("meiji 1 " + month + " " + day);
} else {
System.out.println("pre-meiji");
}
} else {
System.out.println("pre-meiji");
}
} else if (year == 1912) {
if (month > 7) {
System.out.println("taisho 1 " + month + " " + day);
} else if (month == 7) {
if (day >= 30) {
System.out.println("taisho 1 " + month + " " + day);
} else {
System.out.println("meiji " + (year - 1867) + " " + month + " " +
day);
}
} else {
System.out.println("meiji " + (year - 1867) + " " + month + " " +
day);
}
} else if (year == 1926) {
if (month > 12) {
System.out.println("showa 1 " + month + " " + day);
} else if (month == 12) {
if (day >= 25) {
System.out.println("showa 1 " + month + " " + day);
} else {
System.out.println("taisho " + (year - 1911) + " " + month + " " +
day);
}
} else {
System.out.println("taisho " + (year - 1911) + " " + month + " " +
day);
}
} else if (year == 1989) {
if (month > 1) {
System.out.println("heisei 1 " + month + " " + day);
} else if (month == 1) {
if (day >= 8) {
System.out.println("heisei 1 " + month + " " + day);
} else {
System.out.println("showa " + (year - 1925) + " " + month + " " +
day);
}
} else {
System.out.println("showa " + (year - 1925) + " " + month + " " +
day);
}
}
}
}
}
|
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.println("pre-meiji");
} else if (1869 <= year && year <= 1911) {
System.out.println("meiji " + (year - 1867) + " " + month + " " + day);
} else if (1913 <= year && year <= 1925) {
System.out.println("taisho " + (year - 1911) + " " + month + " " + day);
} else if (1927 <= year && year <= 1988) {
System.out.println("showa " + (year - 1925) + " " + month + " " + day);
} else if (1990 <= year) {
System.out.println("heisei " + (year - 1988) + " " + month + " " + day);
}
else if (year == 1868) {
if (month > 9) {
System.out.println("meiji 1 " + month + " " + day);
} else if (month == 9) {
if (day >= 8) {
System.out.println("meiji 1 " + month + " " + day);
} else {
System.out.println("pre-meiji");
}
} else {
System.out.println("pre-meiji");
}
} else if (year == 1912) {
if (month > 7) {
System.out.println("taisho 1 " + month + " " + day);
} else if (month == 7) {
if (day >= 30) {
System.out.println("taisho 1 " + month + " " + day);
} else {
System.out.println("meiji " + (year - 1867) + " " + month + " " +
day);
}
} else {
System.out.println("meiji " + (year - 1867) + " " + month + " " +
day);
}
} else if (year == 1926) {
if (month > 12) {
System.out.println("showa 1 " + month + " " + day);
} else if (month == 12) {
if (day >= 25) {
System.out.println("showa 1 " + month + " " + day);
} else {
System.out.println("taisho " + (year - 1911) + " " + month + " " +
day);
}
} else {
System.out.println("taisho " + (year - 1911) + " " + month + " " +
day);
}
} else if (year == 1989) {
if (month > 1) {
System.out.println("heisei 1 " + month + " " + day);
} else if (month == 1) {
if (day >= 8) {
System.out.println("heisei 1 " + month + " " + day);
} else {
System.out.println("showa " + (year - 1925) + " " + month + " " +
day);
}
} else {
System.out.println("showa " + (year - 1925) + " " + month + " " +
day);
}
}
}
}
}
|
[["-", 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));
String input = null;
while ((input = br.readLine()) != null) {
String[] v = input.split(" ");
int year = Integer.parseInt(v[0]);
int month = Integer.parseInt(v[1]) - 1; // 0 <= month <= 11
int date = Integer.parseInt(v[2]);
String era = transToEra(new GregorianCalendar(year, month, date));
System.out.println(
era + ((era.equals("pre-meiji")) ? "" : " " + month + " " + date));
}
}
public static String transToEra(GregorianCalendar date) {
GregorianCalendar startMeiji =
new GregorianCalendar(1868, Calendar.SEPTEMBER, 8);
GregorianCalendar startTaisho =
new GregorianCalendar(1912, Calendar.JULY, 30);
GregorianCalendar startShowa =
new GregorianCalendar(1926, Calendar.DECEMBER, 25);
GregorianCalendar startHeisei =
new GregorianCalendar(1989, Calendar.JANUARY, 8);
final int yearField = Calendar.YEAR;
if (date.before(startMeiji)) {
return "pre-meiji";
} else if (date.before(startTaisho)) {
return "meiji " + (date.get(yearField) - startMeiji.get(yearField) + 1);
} else if (date.before(startShowa)) {
return "taisho " + (date.get(yearField) - startTaisho.get(yearField) + 1);
} else if (date.before(startHeisei)) {
return "showa " + (date.get(yearField) - startShowa.get(yearField) + 1);
} else {
return "heisei " + (date.get(yearField) - startHeisei.get(yearField) + 1);
}
}
}
|
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));
String input = null;
while ((input = br.readLine()) != null) {
String[] v = input.split(" ");
int year = Integer.parseInt(v[0]);
int month = Integer.parseInt(v[1]) - 1; // 0 <= month <= 11
int date = Integer.parseInt(v[2]);
String era = transToEra(new GregorianCalendar(year, month, date));
System.out.println(era + ((era.equals("pre-meiji"))
? ""
: " " + (month + 1) + " " + date));
}
}
public static String transToEra(GregorianCalendar date) {
GregorianCalendar startMeiji =
new GregorianCalendar(1868, Calendar.SEPTEMBER, 8);
GregorianCalendar startTaisho =
new GregorianCalendar(1912, Calendar.JULY, 30);
GregorianCalendar startShowa =
new GregorianCalendar(1926, Calendar.DECEMBER, 25);
GregorianCalendar startHeisei =
new GregorianCalendar(1989, Calendar.JANUARY, 8);
final int yearField = Calendar.YEAR;
if (date.before(startMeiji)) {
return "pre-meiji";
} else if (date.before(startTaisho)) {
return "meiji " + (date.get(yearField) - startMeiji.get(yearField) + 1);
} else if (date.before(startShowa)) {
return "taisho " + (date.get(yearField) - startTaisho.get(yearField) + 1);
} else if (date.before(startHeisei)) {
return "showa " + (date.get(yearField) - startShowa.get(yearField) + 1);
} else {
return "heisei " + (date.get(yearField) - startHeisei.get(yearField) + 1);
}
}
}
|
[["+", 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,b) a>b?a:b
//#define MIN(a,b) a<b?a:b
int main() {
char ans[100];
int y, m, d;
for (; ~fscanf(stdin, "%d%d%d", &y, &m, &d); P(s, ans)) {
int sirial = y * 416 + m * 32 + d;
if (sirial < 777384)
sprintf(ans, "%s", "pre-maiji");
else if (sirial < 795646)
sprintf(ans, "%s %d %d %d", "maiji", y - 1867, m, d);
else if (sirial < 801625)
sprintf(ans, "%s %d %d %d", "taisho", y - 1911, m, d);
else if (sirial < 827464)
sprintf(ans, "%s %d %d %d", "showa", y - 1925, m, d);
else
sprintf(ans, "%s %d %d %d", "heisei", y - 1988, m, d);
}
return 0;
}
|
#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,b) a>b?a:b
//#define MIN(a,b) a<b?a:b
int main() {
char ans[100];
int y, m, d;
for (; ~fscanf(stdin, "%d%d%d", &y, &m, &d); P(s, ans)) {
int sirial = y * 416 + m * 32 + d;
if (sirial < 777384)
sprintf(ans, "%s", "pre-meiji");
else if (sirial < 795646)
sprintf(ans, "%s %d %d %d", "meiji", y - 1867, m, d);
else if (sirial < 801625)
sprintf(ans, "%s %d %d %d", "taisho", y - 1911, m, d);
else if (sirial < 827464)
sprintf(ans, "%s %d %d %d", "showa", y - 1925, m, d);
else
sprintf(ans, "%s %d %d %d", "heisei", y - 1988, m, d);
}
return 0;
}
|
[["-", 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)))
printf("showa %d %d %d\n", y - 1925, m, d);
else if (y > 1912 || (y == 1912 && (m > 7 || (m == 7 && d >= 30))))
printf("taishow %d %d %d\n", y - 1911, m, d);
else if (y > 1868 || (y == 1868 && (m > 9 || (m == 9 && d >= 8))))
printf("meiji %d %d %d\n", y - 1867, m, d);
else
printf("pre-meiji\n");
}
return 0;
}
|
#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))
printf("showa %d %d %d\n", y - 1925, m, d);
else if (y > 1912 || (y == 1912 && (m > 7 || (m == 7 && d >= 30))))
printf("taisho %d %d %d\n", y - 1911, m, d);
else if (y > 1868 || (y == 1868 && (m > 9 || (m == 9 && d >= 8))))
printf("meiji %d %d %d\n", y - 1867, m, d);
else
printf("pre-meiji\n");
}
return 0;
}
|
[["-", 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, d);
else if (19120730 <= D && D <= 19261224)
printf("taisho %d %d %d\n", y - 1911, m, d);
else if (19261225 <= D && D <= 19890107)
printf("showa %d %d %d\n", y - 1925, m, d);
else if (19890108 <= D)
printf("heisei %d %d %d\n", y - 1988, m, d);
/*printf("a");*/
}
return 0;
}
|
#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, d);
else if (19120730 <= D && D <= 19261224)
printf("taisho %d %d %d\n", y - 1911, m, d);
else if (19261225 <= D && D <= 19890107)
printf("showa %d %d %d\n", y - 1925, m, d);
else if (19890108 <= D)
printf("heisei %d %d %d\n", y - 1988, m, d);
/*printf("a");*/
}
return 0;
}
|
[["-", 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("mieji %d %d %d\n", y - 1867, m, d);
else if (y == 1912 && m < 7)
printf("mieji %d %d %d\n", y - 1867, m, d);
else if (y == 1912 && m == 7 && d <= 29)
printf("mieji %d %d %d\n", y - 1867, m, d);
else if (y < 1926)
printf("taisho %d %d %d\n", y - 1911, m, d);
else if (y == 1926 && m < 12)
printf("taisho %d %d %d\n", y - 1911, m, d);
else if (y == 1926 && m == 12 && d <= 24)
printf("taisho %d %d %d\n", y - 1911, m, d);
else if (y < 1989)
printf("showa %d %d %d\n", y - 1925, m, d);
else if (y == 1989 && m < 1)
printf("showa %d %d %d\n", y - 1925, m, d);
else if (y == 1989 && m == 1 && d <= 7)
printf("showa %d %d %d\n", y - 1925, m, d);
else
printf("heisei %d %d %d\n", y - 1988, m, d);
}
return 0;
}
|
#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("meiji %d %d %d\n", y - 1867, m, d);
else if (y == 1912 && m < 7)
printf("meiji %d %d %d\n", y - 1867, m, d);
else if (y == 1912 && m == 7 && d <= 29)
printf("meiji %d %d %d\n", y - 1867, m, d);
else if (y < 1926)
printf("taisho %d %d %d\n", y - 1911, m, d);
else if (y == 1926 && m < 12)
printf("taisho %d %d %d\n", y - 1911, m, d);
else if (y == 1926 && m == 12 && d <= 24)
printf("taisho %d %d %d\n", y - 1911, m, d);
else if (y < 1989)
printf("showa %d %d %d\n", y - 1925, m, d);
else if (y == 1989 && m < 1)
printf("showa %d %d %d\n", y - 1925, m, d);
else if (y == 1989 && m == 1 && d <= 7)
printf("showa %d %d %d\n", y - 1925, m, d);
else
printf("heisei %d %d %d\n", y - 1988, m, d);
}
return 0;
}
|
[["-", 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\n");
}
break;
case 1912:
if (month > 7 || (month == 7 && date >= 30)) {
printf("taisho 1 %d %d\n", month, date);
} else {
printf("meiji %d %d %d\n", 1912 - 1867, month, date);
}
break;
case 1926:
if (month > 12 || (month == 12 && date >= 25)) {
printf("showa 1 %d %d\n", month, date);
} else {
printf("taisho %d %d %d\n", 1926 - 1911, month, date);
}
break;
case 1989:
if (month > 1 || (month == 1 && date >= 8)) {
printf("heisei 1 %d %d\n", month, date);
} else {
printf("showa %d %d %d\n", 1989 - 1925, month, date);
}
break;
default:
if (year < 1868) {
printf("pre-meiji\n");
} else if (year < 1912) {
printf("meiji %d %d %d\n", year - 1867, month, date);
} else if (year < 1926) {
printf("taisho %d %d %d\n", year - 1911, month, date);
} else if (year < 1989) {
printf("showa %d %d %d\n", year - 1925, month, date);
} else {
printf("heisei %d %d %d\n", year - 1988, month, date);
}
break;
}
}
return 0;
}
|
#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\n");
}
break;
case 1912:
if (month > 7 || (month == 7 && date >= 30)) {
printf("taisho 1 %d %d\n", month, date);
} else {
printf("meiji %d %d %d\n", 1912 - 1867, month, date);
}
break;
case 1926:
if (month > 12 || (month == 12 && date >= 25)) {
printf("showa 1 %d %d\n", month, date);
} else {
printf("taisho %d %d %d\n", 1926 - 1911, month, date);
}
break;
case 1989:
if (month > 1 || (month == 1 && date >= 8)) {
printf("heisei 1 %d %d\n", month, date);
} else {
printf("showa %d %d %d\n", 1989 - 1925, month, date);
}
break;
default:
if (year < 1868) {
printf("pre-meiji\n");
} else if (year < 1912) {
printf("meiji %d %d %d\n", year - 1867, month, date);
} else if (year < 1926) {
printf("taisho %d %d %d\n", year - 1911, month, date);
} else if (year < 1989) {
printf("showa %d %d %d\n", year - 1925, month, date);
} else {
printf("heisei %d %d %d\n", year - 1988, month, date);
}
break;
}
}
return 0;
}
|
[["-", 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) {
printf("taisho %d %d %d\n", y - 1912 + 1, m, d);
} else if (num < 19890108) {
printf("showa %d %d %d\n", y - 1926 + 1, m, d);
} else {
printf("heisei %d %d %d\n", y - 1989 + 1, m, d);
}
}
return 0;
}
|
#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 < 19261225) {
printf("taisho %d %d %d\n", y - 1912 + 1, m, d);
} else if (num < 19890108) {
printf("showa %d %d %d\n", y - 1926 + 1, m, d);
} else {
printf("heisei %d %d %d\n", y - 1989 + 1, m, d);
}
}
return 0;
}
|
[["-", 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, month, date);
} else if (detail < 19261225) {
printf("taisho %d %d %d\n", year - 1911, month, date);
} else if (detail < 19890108) {
printf("showa %d %d %d\n", year - 1925, month, date);
} else {
printf("heisei %d %d %d\n", year - 1988, month, date);
}
}
return (0);
}
|
#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, month, date);
} else if (detail < 19261225) {
printf("taisho %d %d %d\n", year - 1911, month, date);
} else if (detail < 19890108) {
printf("showa %d %d %d\n", year - 1925, month, date);
} else {
printf("heisei %d %d %d\n", year - 1988, month, date);
}
}
return (0);
}
|
[["-", 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, d);
else if (y < 1926 || y == 1926 && m < 12 || y == 1926 && m == 12 && d < 25)
printf("taisyo %d %d %d\n", y - 1911, m, d);
else if (y < 1989 || y == 1989 && m == 1 && d < 8)
printf("showa %d %d %d\n", y - 1925, m, d);
else
printf("heisei %d %d %d\n", y - 1988, m, d);
}
return 0;
}
|
#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, d);
else if (y < 1926 || y == 1926 && m < 12 || y == 1926 && m == 12 && d < 25)
printf("taisho %d %d %d\n", y - 1911, m, d);
else if (y < 1989 || y == 1989 && m == 1 && d < 8)
printf("showa %d %d %d\n", y - 1925, m, d);
else
printf("heisei %d %d %d\n", y - 1988, m, d);
}
return 0;
}
|
[["-", 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, b) for (i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
// memory clear
// ----------------------------------------------------------------------------
#define CLRNUM(a) memset((a), 0, sizeof(a))
#define CLRBOOL(a, flag) memset((a), flag, sizeof(a))
#define CLRCHAR(a) memset((a), '\0', sizeof(a))
// debug
// ----------------------------------------------------------------------------
#define DEBUGINT(x) printf("%d\n", x);
#define DEBUGFLOAT(x) printf("%f\n", x);
#define DEBUGCHAR(x) printf("%c\n", x);
#define DEBUGSTR(x) printf("%s\n", x);
#define DEBUGFORINT(i, a, b, x) \
FOR(i, a, b) { printf("%d ", x[i]); }
#define DEBUGFORFLOAT(i, a, b, x) \
FOR(i, a, b) { printf("%f ", x[i]); }
#define DEBUGFORCHAR(i, a, b, x) \
FOR(i, a, b) { printf("%c ", x[i]); }
#define DEBUGREPINT(i, n, x) \
REP(i, n) { printf("%d ", x[i]); }
#define DEBUGREPFLOAT(i, n, x) \
REP(i, n) { printf("%f ", x[i]); }
#define DEBUGREPCHAR(i, n, x) \
REP(i, n) { printf("%c ", x[i]); }
// other
// ----------------------------------------------------------------------------
#define PUTNL printf("\n")
// constant
// ----------------------------------------------------------------------------
#define INF 1000000000
int main(void) {
int year, month, day;
while (scanf("%d %d %d", &year, &month, &day) != EOF) {
if (year < 1868) {
printf("pre-meiji\n");
}
if (year == 1868) {
if (month <= 9) {
if (month < 9) {
printf("pre-meiji\n");
} else if (month == 9) {
if (day < 8) {
printf("pre-meiji\n");
} else {
printf("meiji %d %d %d\n", year - 1867, month, day);
}
}
} else {
printf("meiji %d %d %d\n", year - 1867, month, day);
}
}
if (year < 1868 && year < 1912) {
printf("meiji %d %d %d\n", year - 1867, month, day);
}
if (year == 1912) {
if (month <= 7) {
if (month < 7) {
printf("meiji %d %d %d\n", year - 1867, month, day);
} else if (month == 7) {
if (day < 30) {
printf("meiji %d %d %d\n", year - 1867, month, day);
} else {
printf("taisho %d %d %d\n", year - 1911, month, day);
}
}
} else {
printf("taisho %d %d %d\n", year - 1911, month, day);
}
}
if (year > 1912 && year < 1926) {
printf("taisho %d %d %d\n", year - 1911, month, day);
}
if (year == 1926) {
if (month <= 12) {
if (month < 12) {
printf("taisho %d %d %d\n", year - 1911, month, day);
} else if (month == 12) {
if (day < 25) {
printf("taisho %d %d %d\n", year - 1911, month, day);
} else {
printf("showa %d %d %d\n", year - 1925, month, day);
}
}
} else {
printf("showa %d %d %d\n", year - 1925, month, day);
}
}
if (year > 1926 && year < 1989) {
printf("showa %d %d %d\n", year - 1925, month, day);
}
if (year == 1989) {
if (month <= 1) {
if (month < 1) {
printf("showa %d %d %d\n", year - 1925, month, day);
} else if (month == 1) {
if (day < 8) {
printf("showa %d %d %d\n", year - 1925, month, day);
} else {
printf("heisei %d %d %d\n", year - 1988, month, day);
}
}
} else {
printf("heisei %d %d %d\n", year - 1988, month, day);
}
}
if (year > 1989) {
printf("heisei %d %d %d\n", year - 1988, month, day);
}
}
return 0;
}
|
// include
// ----------------------------------------------------------------------------
#include <ctype.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// repetition
// ----------------------------------------------------------------------------
#define FOR(i, a, b) for (i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
// memory clear
// ----------------------------------------------------------------------------
#define CLRNUM(a) memset((a), 0, sizeof(a))
#define CLRBOOL(a, flag) memset((a), flag, sizeof(a))
#define CLRCHAR(a) memset((a), '\0', sizeof(a))
// debug
// ----------------------------------------------------------------------------
#define DEBUGINT(x) printf("%d\n", x);
#define DEBUGFLOAT(x) printf("%f\n", x);
#define DEBUGCHAR(x) printf("%c\n", x);
#define DEBUGSTR(x) printf("%s\n", x);
#define DEBUGFORINT(i, a, b, x) \
FOR(i, a, b) { printf("%d ", x[i]); }
#define DEBUGFORFLOAT(i, a, b, x) \
FOR(i, a, b) { printf("%f ", x[i]); }
#define DEBUGFORCHAR(i, a, b, x) \
FOR(i, a, b) { printf("%c ", x[i]); }
#define DEBUGREPINT(i, n, x) \
REP(i, n) { printf("%d ", x[i]); }
#define DEBUGREPFLOAT(i, n, x) \
REP(i, n) { printf("%f ", x[i]); }
#define DEBUGREPCHAR(i, n, x) \
REP(i, n) { printf("%c ", x[i]); }
// other
// ----------------------------------------------------------------------------
#define PUTNL printf("\n")
// constant
// ----------------------------------------------------------------------------
#define INF 1000000000
int main(void) {
int year, month, day;
while (scanf("%d %d %d", &year, &month, &day) != EOF) {
if (year < 1868) {
printf("pre-meiji\n");
}
if (year == 1868) {
if (month <= 9) {
if (month < 9) {
printf("pre-meiji\n");
} else if (month == 9) {
if (day < 8) {
printf("pre-meiji\n");
} else {
printf("meiji %d %d %d\n", year - 1867, month, day);
}
}
} else {
printf("meiji %d %d %d\n", year - 1867, month, day);
}
}
if (year > 1868 && year < 1912) {
printf("meiji %d %d %d\n", year - 1867, month, day);
}
if (year == 1912) {
if (month <= 7) {
if (month < 7) {
printf("meiji %d %d %d\n", year - 1867, month, day);
} else if (month == 7) {
if (day < 30) {
printf("meiji %d %d %d\n", year - 1867, month, day);
} else {
printf("taisho %d %d %d\n", year - 1911, month, day);
}
}
} else {
printf("taisho %d %d %d\n", year - 1911, month, day);
}
}
if (year > 1912 && year < 1926) {
printf("taisho %d %d %d\n", year - 1911, month, day);
}
if (year == 1926) {
if (month <= 12) {
if (month < 12) {
printf("taisho %d %d %d\n", year - 1911, month, day);
} else if (month == 12) {
if (day < 25) {
printf("taisho %d %d %d\n", year - 1911, month, day);
} else {
printf("showa %d %d %d\n", year - 1925, month, day);
}
}
} else {
printf("showa %d %d %d\n", year - 1925, month, day);
}
}
if (year > 1926 && year < 1989) {
printf("showa %d %d %d\n", year - 1925, month, day);
}
if (year == 1989) {
if (month <= 1) {
if (month < 1) {
printf("showa %d %d %d\n", year - 1925, month, day);
} else if (month == 1) {
if (day < 8) {
printf("showa %d %d %d\n", year - 1925, month, day);
} else {
printf("heisei %d %d %d\n", year - 1988, month, day);
}
}
} else {
printf("heisei %d %d %d\n", year - 1988, month, day);
}
}
if (year > 1989) {
printf("heisei %d %d %d\n", year - 1988, month, day);
}
}
return 0;
}
|
[["-", 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 < 7) ||
(a == 1912 && b == 7 && c <= 29)) {
printf("meiji %d %d %d\n", a - meiji + 1, b, c);
} else if ((a <= 1925) || (a == 1926 && b < 12) ||
(a == 1926 && b == 12 && c <= 24)) {
printf("taisho %d %d %d\n", a - taisho + 1, b, c);
} else if ((a <= 1988) || (a == 1989 && b == 1 && c <= 7)) {
printf("taisho %d %d %d\n", a - showa + 1, b, c);
} else {
printf("heisei %d %d %d\n", a - heisei + 1, b, c);
}
}
return 0;
}
|
#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 < 7) ||
(a == 1912 && b == 7 && c <= 29)) {
printf("meiji %d %d %d\n", a - meiji + 1, b, c);
} else if ((a <= 1925) || (a == 1926 && b < 12) ||
(a == 1926 && b == 12 && c <= 24)) {
printf("taisho %d %d %d\n", a - taisho + 1, b, c);
} else if ((a <= 1988) || (a == 1989 && b == 1 && c <= 7)) {
printf("showa %d %d %d\n", a - showa + 1, b, c);
} else {
printf("heisei %d %d %d\n", a - heisei + 1, b, c);
}
}
return 0;
}
|
[["-", 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 %d %d\n", y - 1911, m, d);
else if (num < 19890108)
printf("showa %d %d %d\n", y - 1925, m, d);
else
printf("heisei %d %d %d\n", y - 1988, m, d);
}
return 0;
}
|
#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 %d\n", y - 1911, m, d);
else if (num < 19890108)
printf("showa %d %d %d\n", y - 1925, m, d);
else
printf("heisei %d %d %d\n", y - 1988, m, d);
}
return 0;
}
|
[["-", 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 || (month == 7 && date < 30)))) {
printf("meiji %d %d %d\n", year - 1867, month, date);
} else if (year < 1926 ||
(year == 1926 && (month < 12 || (month == 12 && date < 25)))) {
printf("taisho %d %d %d\n", year - 1911, month, date);
} else if (year < 1989 ||
(year == 1989 && (month < 1 || (month == 1 && date < 8)))) {
printf("taisho %d %d %d\n", year - 1925, month, date);
} else {
printf("heisei %d %d %d\n", year - 1988, month, date);
}
}
return 0;
}
|
#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 || (month == 7 && date < 30)))) {
printf("meiji %d %d %d\n", year - 1867, month, date);
} else if (year < 1926 ||
(year == 1926 && (month < 12 || (month == 12 && date < 25)))) {
printf("taisho %d %d %d\n", year - 1911, month, date);
} else if (year < 1989 ||
(year == 1989 && (month < 1 || (month == 1 && date < 8)))) {
printf("showa %d %d %d\n", year - 1925, month, date);
} else {
printf("heisei %d %d %d\n", year - 1988, month, date);
}
}
return 0;
}
|
[["-", 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 == '-')
m = true, c = gcu();
do {
n = 10 * n + (c - '0'), c = gcu();
} while (c >= '0');
return m ? -n : n;
} //&&c<='9'
_in() { return in<int>(gcu()); }
_T T scan(T &n) {
int c = gcu();
return c == EOF ? false : (n = in<T>(c), true);
}
_sc(char &c) {
c = gcu();
gcu();
return c != EOF;
}
#ifdef _GLIBCXX_STRING
_sc(string &s) {
int c;
s = "";
for (;;) {
c = gcu();
if (c == '\n' || c == ' ')
return true;
else if (c == EOF)
return false;
s += c;
}
}
#endif
_HT _sc(H &h, T &&...t) { return scan(h) && scan(t...); }
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s) {
while (*s)
pcu(*s++);
}
_vo(char c) { pcu(c); }
#ifdef _GLIBCXX_STRING
_vo(string s) {
for (char c : s)
pcu(c);
}
#endif
_T _vo(T n) {
static char buf[20];
char *p = buf;
if (n < 0)
pcu('-'), n *= -1;
if (!n)
*p++ = '0';
else
while (n)
*p++ = n % 10 + '0', n /= 10;
while (p != buf)
pcu(*--p);
}
_vl() { out('\n'); }
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v) {
for (T &x : v)
out(&x == &v[0] ? "" : " "), out(x);
outl();
}
#endif
_HT _vo(H &&h, T &&...t) {
out(h);
out(move(t)...);
}
template <typename... T> _vl(T &&...t) {
out(move(t)...);
outl();
}
int main() {
int y, m = 0, d = 0;
while (scan(y, m, d)) {
int t = 10000 * y + 100 * m + d;
if (t < 18680908) {
outl("pre-meiji");
break;
} else if (t < 19120730)
out("meiji ", y - 1867);
else if (t < 19261225)
out("taisho ", y - 1911);
else if (t < 19890108)
out("showa ", y - 1925);
else
out("heisei ", y - 1988);
outl(' ', m, ' ', d);
}
}
|
#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 == '-')
m = true, c = gcu();
do {
n = 10 * n + (c - '0'), c = gcu();
} while (c >= '0');
return m ? -n : n;
} //&&c<='9'
_in() { return in<int>(gcu()); }
_T T scan(T &n) {
int c = gcu();
return c == EOF ? false : (n = in<T>(c), true);
}
_sc(char &c) {
c = gcu();
gcu();
return c != EOF;
}
#ifdef _GLIBCXX_STRING
_sc(string &s) {
int c;
s = "";
for (;;) {
c = gcu();
if (c == '\n' || c == ' ')
return true;
else if (c == EOF)
return false;
s += c;
}
}
#endif
_HT _sc(H &h, T &&...t) { return scan(h) && scan(t...); }
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s) {
while (*s)
pcu(*s++);
}
_vo(char c) { pcu(c); }
#ifdef _GLIBCXX_STRING
_vo(string s) {
for (char c : s)
pcu(c);
}
#endif
_T _vo(T n) {
static char buf[20];
char *p = buf;
if (n < 0)
pcu('-'), n *= -1;
if (!n)
*p++ = '0';
else
while (n)
*p++ = n % 10 + '0', n /= 10;
while (p != buf)
pcu(*--p);
}
_vl() { out('\n'); }
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v) {
for (T &x : v)
out(&x == &v[0] ? "" : " "), out(x);
outl();
}
#endif
_HT _vo(H &&h, T &&...t) {
out(h);
out(move(t)...);
}
template <typename... T> _vl(T &&...t) {
out(move(t)...);
outl();
}
int main() {
int y, m = 0, d = 0;
while (scan(y, m, d)) {
int t = 10000 * y + 100 * m + d;
if (t < 18680908) {
outl("pre-meiji");
continue;
} else if (t < 19120730)
out("meiji ", y - 1867);
else if (t < 19261225)
out("taisho ", y - 1911);
else if (t < 19890108)
out("showa ", y - 1925);
else
out("heisei ", y - 1988);
outl(' ', m, ' ', d);
}
}
|
[["-", 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 impmonth;
int impday;
while (scanf("%d %d %d", &impyear, &impmonth, &impday) != EOF) {
print_gengo(impyear, impmonth, impday);
}
return 0;
}
void print_gengo(int nen, int tuki, int hi) {
int gengo; // using defined number
// judging statement
if (nen > 1989 || (nen == 1989 && (tuki > 1 || (tuki == 1 && hi >= 8)))) {
gengo = Heisei;
} else if (nen > 1926 ||
(nen == 1926 && (tuki > 12 || (tuki == 12 && hi >= 25)))) {
gengo = Showa;
} else if (nen > 1912 ||
(nen == 1912 && (tuki > 7 || (tuki == 7 && hi >= 30)))) {
gengo = Taisho;
} else if (nen > 1868 ||
(nen == 1868 && (tuki > 9 || (tuki == 9 && hi >= 8)))) {
gengo = Meiji;
} else {
gengo = Pre;
}
// printing statement
switch (gengo) {
case Pre:
printf("pre-meiji\n");
break;
case Meiji:
printf("meigi %d %d %d\n", nen - 1867, tuki, hi);
break;
case Taisho:
printf("taisho %d %d %d\n", nen - 1911, tuki, hi);
break;
case Showa:
printf("showa %d %d %d\n", nen - 1925, tuki, hi);
break;
case Heisei:
printf("heisei %d %d %d\n", nen - 1988, tuki, hi);
break;
}
}
|
#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 impmonth;
int impday;
while (scanf("%d %d %d", &impyear, &impmonth, &impday) != EOF) {
print_gengo(impyear, impmonth, impday);
}
return 0;
}
void print_gengo(int nen, int tuki, int hi) {
int gengo; // using defined number
// judging statement
if (nen > 1989 || (nen == 1989 && (tuki > 1 || (tuki == 1 && hi >= 8)))) {
gengo = Heisei;
} else if (nen > 1926 ||
(nen == 1926 && (tuki > 12 || (tuki == 12 && hi >= 25)))) {
gengo = Showa;
} else if (nen > 1912 ||
(nen == 1912 && (tuki > 7 || (tuki == 7 && hi >= 30)))) {
gengo = Taisho;
} else if (nen > 1868 ||
(nen == 1868 && (tuki > 9 || (tuki == 9 && hi >= 8)))) {
gengo = Meiji;
} else {
gengo = Pre;
}
// printing statement
switch (gengo) {
case Pre:
printf("pre-meiji\n");
break;
case Meiji:
printf("meiji %d %d %d\n", nen - 1867, tuki, hi);
break;
case Taisho:
printf("taisho %d %d %d\n", nen - 1911, tuki, hi);
break;
case Showa:
printf("showa %d %d %d\n", nen - 1925, tuki, hi);
break;
case Heisei:
printf("heisei %d %d %d\n", nen - 1988, tuki, hi);
break;
}
}
|
[["-", 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};
int compare_date(int y1, int m1, int d1, int y2, int m2, int d2);
int era_of_date(int year, int month, int date);
void print_date(int era, int year, int month, int date);
int main() {
int year, month, day;
while (scanf("%d%d%d", &year, &month, &day) != EOF) {
int era = era_of_date(year, month, day);
print_date(era, year, month, day);
}
return 0;
}
// y1/m1/d1 と y2/m2/d2
// を比較し、前者が早ければ負、後者が早ければ正、同じなら0を返す
int compare_date(int y1, int m1, int d1, int y2, int m2, int d2) {
if (y1 < y2) {
return -1;
} else if (y1 > y2) {
return 1;
}
// y1 == y2
if (m1 < m2) {
return -1;
} else if (m1 > m2) {
return 1;
}
// y1 == y2, m1 == m2
if (d1 < d2) {
return -1;
} else if (d1 > d2) {
return 1;
}
// same date
return 0;
}
int era_of_date(int year, int month, int date) {
int era = -1;
for (; era < ERA_HEISEI; era++) {
// 次の元号の開始日と比較する
int compare_result =
compare_date(year, month, date, ERA_BEGIN_YEAR[era + 1],
ERA_BEGIN_MONTH[era + 1], ERA_BEGIN_DATE[era + 1]);
if (compare_result < 0) {
break;
}
}
return era;
}
void print_date(int era, int year, int month, int date) {
//まずは元号を出力する
bool pre_meiji = false;
if (era == ERA_MEIJI) {
printf("meiji");
} else if (era == ERA_TAISHO) {
printf("taihso");
} else if (era == ERA_SHOWA) {
printf("showa");
} else if (era == ERA_HEISEI) {
printf("heisei");
} else {
printf("pre-meiji");
pre_meiji = true;
}
//明治以降なら日付も出力する
if (!pre_meiji) {
printf(" %d %d %d", year - ERA_BEGIN_YEAR[era] + 1, month, date);
}
//最後に改行しておしまい
printf("\n");
}
|
#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};
int compare_date(int y1, int m1, int d1, int y2, int m2, int d2);
int era_of_date(int year, int month, int date);
void print_date(int era, int year, int month, int date);
int main() {
int year, month, day;
while (scanf("%d%d%d", &year, &month, &day) != EOF) {
int era = era_of_date(year, month, day);
print_date(era, year, month, day);
}
return 0;
}
// y1/m1/d1 と y2/m2/d2
// を比較し、前者が早ければ負、後者が早ければ正、同じなら0を返す "2014/7/50"
// のように正規化されていないものは扱わない
int compare_date(int y1, int m1, int d1, int y2, int m2, int d2) {
if (y1 < y2) {
return -1;
} else if (y1 > y2) {
return 1;
}
//以下、年が同じである場合
if (m1 < m2) {
return -1;
} else if (m1 > m2) {
return 1;
}
//以下、年と月が同じである場合
if (d1 < d2) {
return -1;
} else if (d1 > d2) {
return 1;
}
//同じ日付である場合
return 0;
}
int era_of_date(int year, int month, int date) {
int era = -1;
//元号の線形探索を行う
for (; era < ERA_HEISEI; era++) {
// 次の元号の開始日と比較する
int compare_result =
compare_date(year, month, date, ERA_BEGIN_YEAR[era + 1],
ERA_BEGIN_MONTH[era + 1], ERA_BEGIN_DATE[era + 1]);
if (compare_result < 0) {
break;
}
}
return era;
}
void print_date(int era, int year, int month, int date) {
//まずは元号を出力する
bool pre_meiji = false;
if (era == ERA_MEIJI) {
printf("meiji");
} else if (era == ERA_TAISHO) {
printf("taisho");
} else if (era == ERA_SHOWA) {
printf("showa");
} else if (era == ERA_HEISEI) {
printf("heisei");
} else {
printf("pre-meiji");
pre_meiji = true;
}
//明治以降なら日付も出力する
if (!pre_meiji) {
printf(" %d %d %d", year - ERA_BEGIN_YEAR[era] + 1, month, date);
}
//最後に改行しておしまい
printf("\n");
}
|
[["-", 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, 24},
{1926, 12, 25, 1989, 1, 7},
{1989, 1, 8, 3000, 12, 31}};
const string name[4] = {"meiji", "taisho", "showa", "heisei"};
int main(void) {
int y, m, d;
while (cin >> y >> m >> d) {
if (y < table[0][Yb] || (y == table[0][Yb] && m < table[0][Mb]) ||
(y == table[0][Yb] && m == table[0][Mb] && d < table[0][Db])) {
cout << "pre-meiji" << endl;
continue;
}
bool find = false;
loop(i, 1, 3) {
if (y < table[i][Ye] || (y == table[i][Ye] && m < table[i][Me]) ||
(y == table[i][Ye] && m == table[i][Me] && d < table[i][De])) {
cout << name[i] << " " << y - table[i - 1][Ye] + 1 << " " << m << " "
<< d << endl;
find = true;
break;
}
}
if (find)
continue;
cout << name[3] << " " << y - table[3][Yb] + 1 << " " << m << " " << d
<< endl;
}
}
|
#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, 24},
{1926, 12, 25, 1989, 1, 7},
{1989, 1, 8, 3000, 12, 31}};
const string name[4] = {"meiji", "taisho", "showa", "heisei"};
int main(void) {
int y, m, d;
while (cin >> y >> m >> d) {
if (y < table[0][Yb] || (y == table[0][Yb] && m < table[0][Mb]) ||
(y == table[0][Yb] && m == table[0][Mb] && d < table[0][Db])) {
cout << "pre-meiji" << endl;
continue;
}
bool find = false;
loop(i, 0, 3) {
if (y < table[i][Ye] || (y == table[i][Ye] && m < table[i][Me]) ||
(y == table[i][Ye] && m == table[i][Me] && d <= table[i][De])) {
cout << name[i] << " " << y - table[i][Yb] + 1 << " " << m << " " << d
<< endl;
find = true;
break;
}
}
if (find)
continue;
cout << name[3] << " " << y - table[3][Yb] + 1 << " " << m << " " << d
<< endl;
}
}
|
[["-", 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], ["+", 12, 16, 31, 16, 12, 69, 341, 342, 0, 22]]
| 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 = 2;
else if (p < 19890108)
c = 3;
else
c = 4;
cout << str[c];
switch (c) {
case 1:
cout << " " << y - 1868 + 1;
case 2:
cout << " " << y - 1912 + 1;
case 3:
cout << " " << y - 1926 + 1;
case 4:
cout << " " << y - 1989 + 1;
}
if (c != 0) {
cout << " " << m << " " << d;
}
cout << endl;
}
}
|
#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 = 2;
else if (p < 19890108)
c = 3;
else
c = 4;
cout << str[c];
switch (c) {
case 1:
cout << " " << y - 1868 + 1;
break;
case 2:
cout << " " << y - 1912 + 1;
break;
case 3:
cout << " " << y - 1926 + 1;
break;
case 4:
cout << " " << y - 1989 + 1;
}
if (c != 0) {
cout << " " << m << " " << d;
}
cout << endl;
}
}
|
[["+", 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 >= 19120730) {
printf("taisho ");
x = x - 1911;
} else if (n1 >= 18680908) {
printf("meiji ");
x = x - 1985;
} else if (n1 < 18680908)
printf("pre-meiji\n");
if (n1 >= 18680908)
printf("%d %d %d\n", x, y, z);
n1 = 0;
}
return 0;
}
|
#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 >= 19120730) {
printf("taisho ");
x = x - 1911;
} else if (n1 >= 18680908) {
printf("meiji ");
x = x - 1867;
} else if (n1 < 18680908)
printf("pre-meiji\n");
if (n1 >= 18680908)
printf("%d %d %d\n", x, y, z);
n1 = 0;
}
return 0;
}
|
[["-", 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", year - 1867, month, day);
} else if (era == 't') {
printf("taisho %d %d %d\n", year - 1911, month, day);
} else if (era == 's') {
printf("showa %d %d %d\n", year - 1925, month, day);
} else if (era == 'h') {
printf("heisei %d %d %d\n", year - 1988, month, day);
}
}
return 0;
}
char judge(int year, int month, int day) {
// pre-meiji or meiji
if (year < 1868) {
return 'p';
} else if (year == 1868) {
if (month < 9) {
return 'p';
} else if (month == 9) {
if (day < 8) {
return 'p';
} else {
return 'm';
}
} else {
return 'm';
}
} else if (year < 1912) {
// meiji or taisho
return 'm';
} else if (year == 1912) {
if (month < 7) {
return 'm';
} else if (month == 7) {
if (day < 30) {
return 'm';
} else {
return 't';
}
} else {
return 't';
}
} else if (year < 1926) {
// taisho or showa
return 't';
} else if (year == 1926) {
if (month < 12) {
return 't';
} else if (month == 12) {
if (day < 25) {
return 't';
} else {
return 's';
}
} else {
return 's';
}
} else if (year < 1989) {
return 's';
} else if (year == 1989) {
if (month == 1) {
if (day < 8) {
return 's';
} else {
return 'h';
}
}
return 'h';
} else {
return 'h';
}
}
|
#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", year - 1867, month, day);
} else if (era == 't') {
printf("taisho %d %d %d\n", year - 1911, month, day);
} else if (era == 's') {
printf("showa %d %d %d\n", year - 1925, month, day);
} else if (era == 'h') {
printf("heisei %d %d %d\n", year - 1988, month, day);
}
}
return 0;
}
char judge(int year, int month, int day) {
// pre-meiji or meiji
if (year < 1868) {
return 'p';
} else if (year == 1868) {
if (month < 9) {
return 'p';
} else if (month == 9) {
if (day < 8) {
return 'p';
} else {
return 'm';
}
} else {
return 'm';
}
} else if (year < 1912) {
// meiji or taisho
return 'm';
} else if (year == 1912) {
if (month < 7) {
return 'm';
} else if (month == 7) {
if (day < 30) {
return 'm';
} else {
return 't';
}
} else {
return 't';
}
} else if (year < 1926) {
// taisho or showa
return 't';
} else if (year == 1926) {
if (month < 12) {
return 't';
} else if (month == 12) {
if (day < 25) {
return 't';
} else {
return 's';
}
} else {
return 's';
}
} else if (year < 1989) {
return 's';
} else if (year == 1989) {
if (month == 1) {
if (day < 8) {
return 's';
} else {
return 'h';
}
}
return 'h';
} else {
return 'h';
}
}
|
[["-", 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 && month <= 8) ||
(year == 1868 && month == 9 && day <= 7)) {
printf("pre-maiji\n");
} else if (year <= 1911 || (year == 1912 && month <= 6) ||
(year == 1912 && month == 7 && day <= 29)) {
int year_wareki = (year - 1867);
printf("meiji %d %d %d\n", year_wareki, month, day);
} else if (year <= 1925 || (year == 1926 && month <= 11) ||
(year == 1926 && month == 12 && day <= 24)) {
int year_wareki = (year - 1911);
printf("taisho %d %d %d\n", year_wareki, month, day);
} else if (year <= 1988 || (year == 1989 && month == 1 && day <= 7)) {
int year_wareki = (year - 1925);
printf("showa %d %d %d\n", year_wareki, month, day);
} else {
int year_wareki = (year - 1988);
printf("heisei %d %d %d\n", year_wareki, month, day);
}
}
|
#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 && month <= 8) ||
(year == 1868 && month == 9 && day <= 7)) {
printf("pre-meiji\n");
} else if (year <= 1911 || (year == 1912 && month <= 6) ||
(year == 1912 && month == 7 && day <= 29)) {
int year_wareki = (year - 1867);
printf("meiji %d %d %d\n", year_wareki, month, day);
} else if (year <= 1925 || (year == 1926 && month <= 11) ||
(year == 1926 && month == 12 && day <= 24)) {
int year_wareki = (year - 1911);
printf("taisho %d %d %d\n", year_wareki, month, day);
} else if (year <= 1988 || (year == 1989 && month == 1 && day <= 7)) {
int year_wareki = (year - 1925);
printf("showa %d %d %d\n", year_wareki, month, day);
} else {
int year_wareki = (year - 1988);
printf("heisei %d %d %d\n", year_wareki, month, day);
}
}
|
[["-", 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) {
//年月日をくっつけて、大小を比較する。
// intが16bitだと死ぬので32bitで指定する。
int32_t year_month_day = year * 10000 + month * 100 + day;
if (year_month_day < 18680908) {
printf("pre-meiji\n");
} else if (year_month_day <= 19120709) {
printf("meiji %d %d %d\n", year - 1868 + 1, month, day);
} else if (year_month_day <= 19261224) {
printf("taisho %d %d %d\n", year - 1912 + 1, month, day);
} else if (year_month_day <= 19890107) {
printf("showa %d %d %d^n", year - 1926 + 1, month, day);
} else {
printf("heisei %d %d %d\n", year - 1989 + 1, month, 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) {
//年月日をくっつけて、大小を比較する。
// intが16bitだと死ぬので32bitで指定する。
int32_t year_month_day = year * 10000 + month * 100 + day;
if (year_month_day < 18680908) {
printf("pre-meiji\n");
} else if (year_month_day <= 19120729) {
printf("meiji %d %d %d\n", year - 1868 + 1, month, day);
} else if (year_month_day <= 19261224) {
printf("taisho %d %d %d\n", year - 1912 + 1, month, day);
} else if (year_month_day <= 19890107) {
printf("showa %d %d %d\n", year - 1926 + 1, month, day);
} else {
printf("heisei %d %d %d\n", year - 1989 + 1, month, 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 == 12 && d >= 25)) {
cout << "showa " << y - 1926 + 1 << " " << m << " " << d << endl;
} else if (y >= 1913 || (y == 1912 && m >= 8) ||
(y == 1912 && m == 7 && d >= 30)) {
cout << "taisho " << y - 1913 + 1 << " " << m << " " << d << endl;
} else if (y >= 1869 || (y == 1868 && m >= 10) ||
(y == 1868 && m >= 9 && d >= 8)) {
cout << "meiji " << y - 1868 + 1 << " " << m << " " << d << endl;
} else {
cout << "pre-meiji " << endl;
}
}
return 0;
}
|
#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 == 12 && d >= 25)) {
cout << "showa " << y - 1926 + 1 << " " << m << " " << d << endl;
} else if (y >= 1913 || (y == 1912 && m >= 8) ||
(y == 1912 && m == 7 && d >= 30)) {
cout << "taisho " << y - 1912 + 1 << " " << m << " " << d << endl;
} else if (y >= 1869 || (y == 1868 && m >= 10) ||
(y == 1868 && m >= 9 && d >= 8)) {
cout << "meiji " << y - 1868 + 1 << " " << m << " " << d << endl;
} else {
cout << "pre-meiji" << endl;
}
}
return 0;
}
|
[["-", 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 (cin >> year >> month >> day) {
if (year > 1989 || (year == 1989 && month > 1) ||
(year == 1989 && month == 1 && day >= 8))
cout << "heisei " << -1 * (1989 - 1 - year) << ' ' << month << ' ' << day
<< endl;
else if (year > 1926 || (year == 1926 && month > 12) ||
(year == 1926 && month == 12 && day >= 25))
cout << "syowa " << -1 * (1926 - 1 - year) << ' ' << month << ' ' << day
<< endl;
else if (year > 1912 || (year == 1912 && month > 7) ||
(year == 1912 && month == 7 && day >= 30))
cout << "taisho " << -1 * (1912 - 1 - year) << ' ' << month << ' ' << day
<< endl;
else if (year > 1868 || (year == 1868 && month > 9) ||
(year == 1868 && month == 9 && day >= 8))
cout << "meiji " << -1 * (1868 - 1 - year) << ' ' << month << ' ' << day
<< endl;
else
cout << "pre-meiji" << endl;
}
}
|
#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 (cin >> year >> month >> day) {
if (year > 1989 || (year == 1989 && month > 1) ||
(year == 1989 && month == 1 && day >= 8))
cout << "heisei " << -1 * (1989 - 1 - year) << ' ' << month << ' ' << day
<< endl;
else if (year > 1926 || (year == 1926 && month > 12) ||
(year == 1926 && month == 12 && day >= 25))
cout << "showa " << -1 * (1926 - 1 - year) << ' ' << month << ' ' << day
<< endl;
else if (year > 1912 || (year == 1912 && month > 7) ||
(year == 1912 && month == 7 && day >= 30))
cout << "taisho " << -1 * (1912 - 1 - year) << ' ' << month << ' ' << day
<< endl;
else if (year > 1868 || (year == 1868 && month > 9) ||
(year == 1868 && month == 9 && day >= 8))
cout << "meiji " << -1 * (1868 - 1 - year) << ' ' << month << ' ' << day
<< endl;
else
cout << "pre-meiji" << endl;
}
}
|
[["-", 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 && m > 7 || y == 1912 && m == 7 && d >= 30) {
ny -= 44;
a = "taisho ";
}
if (y > 1926 || y == 1926 && m > 12 || y == 1926 && m == 12 && d >= 25) {
ny -= 14;
a = "showa ";
}
if (y > 1989 || y == 1989 && m > 1 || y == 1989 && m == 1 && d >= 8) {
ny -= 63;
a = "heisei ";
}
cout << a;
if (a != "pre-meiji")
cout << ny << " " << m << " " << d << endl;
}
return 0;
}
|
#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 && m > 7 || y == 1912 && m == 7 && d >= 30) {
ny -= 44;
a = "taisho ";
}
if (y > 1926 || y == 1926 && m > 12 || y == 1926 && m == 12 && d >= 25) {
ny -= 14;
a = "showa ";
}
if (y > 1989 || y == 1989 && m > 1 || y == 1989 && m == 1 && d >= 8) {
ny -= 63;
a = "heisei ";
}
cout << a;
if (a != "pre-meiji")
cout << ny << " " << m << " " << d;
cout << endl;
}
return 0;
}
|
[["+", 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 += (is_leap(y) ? 29 : 28);
else if (i == 4 || i == 6 || i == 9 || i == 11)
ret += 30;
else
ret += 31;
}
return ret + d;
}
int main() {
while (~scanf("%d%d%d", &Y, &M, &D)) {
if (count(Y, M, D) >= count(1989, 1, 8))
printf("heisei %d %d %d\n", Y - 1988, M, D);
if (count(Y, M, D) >= count(1926, 12, 25))
printf("heisei %d %d %d\n", Y - 1925, M, D);
if (count(Y, M, D) >= count(1912, 7, 30))
printf("heisei %d %d %d\n", Y - 1911, M, D);
if (count(Y, M, D) >= count(1868, 9, 8))
printf("heisei %d %d %d\n", Y - 1867, M, D);
else
printf("pre-meiji\n");
}
}
|
#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 += (is_leap(y) ? 29 : 28);
else if (i == 4 || i == 6 || i == 9 || i == 11)
ret += 30;
else
ret += 31;
}
return ret + d;
}
int main() {
while (~scanf("%d%d%d", &Y, &M, &D)) {
if (count(Y, M, D) >= count(1989, 1, 8))
printf("heisei %d %d %d\n", Y - 1988, M, D);
else if (count(Y, M, D) >= count(1926, 12, 25))
printf("showa %d %d %d\n", Y - 1925, M, D);
else if (count(Y, M, D) >= count(1912, 7, 30))
printf("taisho %d %d %d\n", Y - 1911, M, D);
else if (count(Y, M, D) >= count(1868, 9, 8))
printf("meiji %d %d %d\n", Y - 1867, M, D);
else
printf("pre-meiji\n");
}
}
|
[["+", 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 && num < n[1]) {
cout << "meiji " << y - 1867 << ' ' << m << ' ' << d;
} else if (n[1] <= num && num < n[2]) {
cout << "taisho " << y - 1911 << ' ' << m << ' ' << d;
} else if (n[2] <= num && num < n[3]) {
cout << "showa " << y - 1925 << ' ' << m << ' ' << d;
} else if (n[3] <= num) {
cout << "heisei " << y - 1988 << ' ' << m << ' ' << d;
} else {
cout << "pre-meiji";
}
cout << endl;
return (0);
}
|
#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] <= num && num < n[1]) {
cout << "meiji " << y - 1867 << ' ' << m << ' ' << d;
} else if (n[1] <= num && num < n[2]) {
cout << "taisho " << y - 1911 << ' ' << m << ' ' << d;
} else if (n[2] <= num && num < n[3]) {
cout << "showa " << y - 1925 << ' ' << m << ' ' << d;
} else if (n[3] <= num) {
cout << "heisei " << y - 1988 << ' ' << m << ' ' << d;
} else {
cout << "pre-meiji";
}
cout << endl;
}
return (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:\D_Download\Visual
///Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
int main() {
while (1) {
int y, m, d;
if (!(cin >> y >> m >> d)) {
return 0;
} else {
int hash = y * 10000 + m * 100 + d;
string gou;
if (hash >= 1989 * 10000 + 1 * 100 + 8) {
gou = "heisei";
} else if (hash >= 1926 * 10000 + 12 * 100 + 25) {
gou = "syowa";
} else if (hash >= 1912 * 10000 + 7 * 100 + 30) {
gou = "taisho";
} else if (hash >= 1868 * 10000 + 9 * 100 + 8) {
gou = "meiji";
} else {
gou = "pre-meiji";
}
if (gou == "pre-meiji") {
cout << gou << endl;
} else {
cout << gou << " ";
map<string, int> mp;
mp["heisei"] = 1988;
mp["showa"] = 1925;
mp["taisho"] = 1911;
mp["meiji"] = 1867;
cout << y - mp[gou] << " " << m << " " << d << endl;
}
}
}
return 0;
}
|
#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T> using Table = vector<vector<T>>;
const ld eps = 1e-9;
//// < "D:\D_Download\Visual Studio
///2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual
///Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
int main() {
while (1) {
int y, m, d;
if (!(cin >> y >> m >> d)) {
return 0;
} else {
int hash = y * 10000 + m * 100 + d;
string gou;
if (hash >= 1989 * 10000 + 1 * 100 + 8) {
gou = "heisei";
} else if (hash >= 1926 * 10000 + 12 * 100 + 25) {
gou = "showa";
} else if (hash >= 1912 * 10000 + 7 * 100 + 30) {
gou = "taisho";
} else if (hash >= 1868 * 10000 + 9 * 100 + 8) {
gou = "meiji";
} else {
gou = "pre-meiji";
}
if (gou == "pre-meiji") {
cout << gou << endl;
} else {
cout << gou << " ";
map<string, int> mp;
mp["heisei"] = 1988;
mp["showa"] = 1925;
mp["taisho"] = 1911;
mp["meiji"] = 1867;
cout << y - mp[gou] << " " << m << " " << d << endl;
}
}
}
return 0;
}
|
[["-", 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)
return 1;
if (this->d < d2.d)
return -1;
if (this->d > d2.d)
return 1;
return 0;
}
int cmp(int y, int m, int d) {
Date *tmp = new Date(y, m, d);
return cmp(*tmp);
}
};
int main(void) {
int y, m, d;
while (scanf("%d%d%d", &y, &m, &d) != EOF) {
Date *date = new Date(y, m, d);
if (date->cmp(1868, 9, 8) == -1) {
puts("pre-meiji");
} else if (date->cmp(1912, 7, 30) == -1) {
printf("meiji %d %d %d\n", y - 1868 + 1, m, d);
} else if (date->cmp(1926, 12, 25) == -1) {
printf("taisho %d %d %d\n", y - 1912 + 1, m, d);
} else if (date->cmp(1989, 1, 8) == -1) {
printf("taisho %d %d %d\n", y - 1926 + 1, m, d);
} else {
printf("heisei %d %d %d\n", y - 1989 + 1, m, d);
}
delete date;
}
return 0;
}
|
#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)
return 1;
if (this->d < d2.d)
return -1;
if (this->d > d2.d)
return 1;
return 0;
}
int cmp(int y, int m, int d) {
Date *tmp = new Date(y, m, d);
return cmp(*tmp);
}
};
int main(void) {
int y, m, d;
while (scanf("%d%d%d", &y, &m, &d) != EOF) {
Date *date = new Date(y, m, d);
if (date->cmp(1868, 9, 8) == -1) {
puts("pre-meiji");
} else if (date->cmp(1912, 7, 30) == -1) {
printf("meiji %d %d %d\n", y - 1868 + 1, m, d);
} else if (date->cmp(1926, 12, 25) == -1) {
printf("taisho %d %d %d\n", y - 1912 + 1, m, d);
} else if (date->cmp(1989, 1, 8) == -1) {
printf("showa %d %d %d\n", y - 1926 + 1, m, d);
} else {
printf("heisei %d %d %d\n", y - 1989 + 1, m, d);
}
delete date;
}
return 0;
}
|
[["-", 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 == 9) {
if (c < 8) {
era = 1;
} else {
era = 2;
}
} else {
era = 2;
}
} else if (a < 1912) {
era = 2;
} else if (a == 1912) {
if (b < 7) {
era = 2;
} else if (b == 7) {
if (c < 30) {
era = 2;
} else {
era = 3;
}
} else {
era = 3;
}
} else if (a < 1926) {
era = 3;
} else if (a == 1926) {
if (b < 12) {
era = 3;
} else if (b == 12) {
if (c < 25) {
era = 3;
} else {
era = 4;
}
} else {
era = 4;
}
} else if (a < 1989) {
era = 4;
} else if (a == 1989) {
if (b < 1) {
era = 4;
} else if (b == 1) {
if (c < 8) {
era = 4;
} else {
era = 5;
}
} else {
era = 5;
}
} else {
era = 5;
}
if (era == 1) {
cout << "pre-meiji" << endl;
} else {
if (era == 2) {
cout << "meiji " << a - 1867 << " ";
} else if (era == 3) {
cout << "taisho " << a - 1911 << " ";
} else if (era == 4) {
cout << "shiwa " << a - 1925 << " ";
} else if (era == 5) {
cout << "heisei " << a - 1988 << " ";
}
cout << b << " " << c << endl;
}
}
return 0;
}
|
#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 == 9) {
if (c < 8) {
era = 1;
} else {
era = 2;
}
} else {
era = 2;
}
} else if (a < 1912) {
era = 2;
} else if (a == 1912) {
if (b < 7) {
era = 2;
} else if (b == 7) {
if (c < 30) {
era = 2;
} else {
era = 3;
}
} else {
era = 3;
}
} else if (a < 1926) {
era = 3;
} else if (a == 1926) {
if (b < 12) {
era = 3;
} else if (b == 12) {
if (c < 25) {
era = 3;
} else {
era = 4;
}
} else {
era = 4;
}
} else if (a < 1989) {
era = 4;
} else if (a == 1989) {
if (b < 1) {
era = 4;
} else if (b == 1) {
if (c < 8) {
era = 4;
} else {
era = 5;
}
} else {
era = 5;
}
} else {
era = 5;
}
if (era == 1) {
cout << "pre-meiji" << endl;
} else {
if (era == 2) {
cout << "meiji " << a - 1867 << " ";
} else if (era == 3) {
cout << "taisho " << a - 1911 << " ";
} else if (era == 4) {
cout << "showa " << a - 1925 << " ";
} else if (era == 5) {
cout << "heisei " << a - 1988 << " ";
}
cout << b << " " << c << endl;
}
}
return 0;
}
|
[["-", 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 - 1988, b, c);
else
printf("showa %d %d %d\n", a - 1925, b, c);
} else if (a > 1926)
printf("showa %d %d %d\n", a - 1925, b, c);
else if (a == 1926) {
if (b == 12 && c >= 25)
printf("showa %d %d %d\n", a - 1925, b, c);
else
printf("taisho %d %d %d\n", a - 1911, b, c);
} else if (a > 1912)
printf("taisho %d %d %d\n", a - 1911, b, c);
else if (a == 1912) {
if (b > 7)
printf("taisho %d %d %d\n", a - 1911, b, c);
else if (b == 7 && c >= 30)
printf("taisho %d %d %d\n", a - 1911, b, c);
else
printf("meiji %d %d %d\n", a - 1867, b, c);
} else if (a > 1868)
printf("meiji %d %d %d\n", a - 1867, b, c);
else if (a == 1868) {
if (b > 9)
printf("meiji %d %d %d\n", a - 1867, b, c);
else if (b == 9 && c >= 8)
printf("meiji %d %d %d\n", a - 1867, b, c);
else
printf("pre-meiji\n");
} else
printf("pre=meiji\n");
}
}
|
#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 - 1988, b, c);
else
printf("showa %d %d %d\n", a - 1925, b, c);
} else if (a > 1926)
printf("showa %d %d %d\n", a - 1925, b, c);
else if (a == 1926) {
if (b == 12 && c >= 25)
printf("showa %d %d %d\n", a - 1925, b, c);
else
printf("taisho %d %d %d\n", a - 1911, b, c);
} else if (a > 1912)
printf("taisho %d %d %d\n", a - 1911, b, c);
else if (a == 1912) {
if (b > 7)
printf("taisho %d %d %d\n", a - 1911, b, c);
else if (b == 7 && c >= 30)
printf("taisho %d %d %d\n", a - 1911, b, c);
else
printf("meiji %d %d %d\n", a - 1867, b, c);
} else if (a > 1868)
printf("meiji %d %d %d\n", a - 1867, b, c);
else if (a == 1868) {
if (b > 9)
printf("meiji %d %d %d\n", a - 1867, b, c);
else if (b == 9 && c >= 8)
printf("meiji %d %d %d\n", a - 1867, b, c);
else
printf("pre-meiji\n");
} else
printf("pre-meiji\n");
}
}
|
[["-", 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(string name, int st, int fin) {
this->name = name;
this->st = st;
this->fin = fin;
}
void outputString(int y, int m, int d) {
cout << name << ' ' << y - st / 10000 + 1 << ' ' << m << ' ' << d << endl;
}
bool dayOf(int date) { return st <= date && date <= fin; }
private:
string name;
int st, fin; // yyyymmdd
};
int main(void) {
CEra eras[4];
eras[0].Set("meiji", DATE_MEIJI_S, DATE_MEIJI_F);
eras[1].Set("taisho", DATE_TAISHO_S, DATE_TAISHO_F);
eras[2].Set("showa", DATE_SHOWA_S, DATE_SHOWA_F);
eras[3].Set("heisei", DATE_HEISEI_S, 100000000);
while (true) {
int date = 0;
int y, m, d;
bool bElseEra = true;
cin >> y >> m >> d;
if (cin.eof())
break;
date += y * 10000 + m * 100 + d;
for (int i = 0; i < sizeof(eras) / sizeof(*eras); i++) {
if (eras[i].dayOf(date)) {
eras[i].outputString(y, m, d);
bElseEra = false;
}
}
if (bElseEra)
cout << "pre-meiji" << endl;
}
return 0;
}
|
#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(string name, int st, int fin) {
this->name = name;
this->st = st;
this->fin = fin;
}
void outputString(int y, int m, int d) {
cout << name << ' ' << y - st / 10000 + 1 << ' ' << m << ' ' << d << endl;
}
bool dayOf(int date) { return st <= date && date <= fin; }
private:
string name;
int st, fin; // yyyymmdd
};
int main(void) {
CEra eras[4];
eras[0].Set("meiji", DATE_MEIJI_S, DATE_MEIJI_F);
eras[1].Set("taisho", DATE_TAISHO_S, DATE_TAISHO_F);
eras[2].Set("showa", DATE_SHOWA_S, DATE_SHOWA_F);
eras[3].Set("heisei", DATE_HEISEI_S, 100000000);
while (true) {
int date = 0;
int y, m, d;
bool bElseEra = true;
cin >> y >> m >> d;
if (cin.eof())
break;
date += y * 10000 + m * 100 + d;
for (int i = 0; i < sizeof(eras) / sizeof(*eras); i++) {
if (eras[i].dayOf(date)) {
eras[i].outputString(y, m, d);
bElseEra = false;
}
}
if (bElseEra)
cout << "pre-meiji" << endl;
}
return 0;
}
|
[["-", 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 namespace std;
#define reep(i, f, n) for (int i = f; i < int(n); ++i)
#define rep(i, n) reep(i, 0, n)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> Point;
struct Date {
int year, month, day;
Date(int y, int m, int d) : year(y), month(m), day(d) {}
Date() {}
bool operator<(const Date &d) const {
if (year != d.year)
return year < d.year;
if (month != d.month)
return month < d.month;
return day < d.day;
}
};
int main() {
const Date begin[] = {Date(1868, 9, 8), Date(1912, 7, 30), Date(1926, 12, 25),
Date(1989, 1, 8)};
const char *name[] = {"pre_meiji", "meiji", "taisho", "showa", "heisei"};
Date d;
while (scanf("%d%d%d", &d.year, &d.month, &d.day) != EOF) {
int id = distance(begin, upper_bound(begin, begin + 4, d));
if (id)
printf("%s %d %d %d\n", name[id], d.year - begin[id - 1].year + 1,
d.month, d.day);
else
puts(name[id]);
}
return 0;
}
|
#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 namespace std;
#define reep(i, f, n) for (int i = f; i < int(n); ++i)
#define rep(i, n) reep(i, 0, n)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> Point;
struct Date {
int year, month, day;
Date(int y, int m, int d) : year(y), month(m), day(d) {}
Date() {}
bool operator<(const Date &d) const {
if (year != d.year)
return year < d.year;
if (month != d.month)
return month < d.month;
return day < d.day;
}
};
int main() {
const Date begin[] = {Date(1868, 9, 8), Date(1912, 7, 30), Date(1926, 12, 25),
Date(1989, 1, 8)};
const char *name[] = {"pre-meiji", "meiji", "taisho", "showa", "heisei"};
Date d;
while (scanf("%d%d%d", &d.year, &d.month, &d.day) != EOF) {
int id = distance(begin, upper_bound(begin, begin + 4, d));
if (id)
printf("%s %d %d %d\n", name[id], d.year - begin[id - 1].year + 1,
d.month, d.day);
else
puts(name[id]);
}
return 0;
}
|
[["-", 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" << endl;
continue;
}
if (d < 19120730) {
cout << "meiji" << ss << a - 1867 << ss << b << ss << c << endl;
continue;
}
if (d < 19261225) {
cout << "taisho" << ss << a - 1911 << ss << b << ss << c << endl;
continue;
}
if (d < 19890108) {
cout << "showa" << ss << a - 1925 << ss << b << ss << c << endl;
continue;
}
cout << "heisei" << ss << a - 1988 << ss << b << c << endl;
}
return 0;
}
|
#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" << endl;
continue;
}
if (d < 19120730) {
cout << "meiji" << ss << a - 1867 << ss << b << ss << c << endl;
continue;
}
if (d < 19261225) {
cout << "taisho" << ss << a - 1911 << ss << b << ss << c << endl;
continue;
}
if (d < 19890108) {
cout << "showa" << ss << a - 1925 << ss << b << ss << c << endl;
continue;
}
cout << "heisei" << ss << a - 1988 << ss << b << ss << c << endl;
}
return 0;
}
|
[["+", 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;
if (p[j] < 0)
i--;
}
p[j] = -1;
nn--;
if (nn == 0)
break;
}
cout << j << endl;
}
return 0;
}
|
#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;
if (p[j] < 0)
i--;
}
p[j] = -1;
nn--;
if (nn == 0)
break;
}
cout << j << endl;
}
return 0;
}
|
[["-", 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, 11, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
| 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] == 0)
j++;
}
a[p] = 1;
}
printf("%d\n", p);
}
return 0;
}
|
#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)
j++;
}
a[p] = 1;
}
printf("%d\n", p + 1);
}
return 0;
}
|
[["-", 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;
if (!seki[cn]) {
offset++;
}
}
seki[cn] = false;
}
for (int i = 0; i < n; i++) {
if (seki[i])
cout << i << endl;
}
}
}
|
#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;
if (!seki[cn]) {
offset++;
}
}
seki[cn] = false;
}
for (int i = 0; i < n; i++) {
if (seki[i])
cout << i + 1 << endl;
}
}
}
|
[["-", 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
while any(ary):
count = m
while count:
index = (index+1) % n
if ary[index]:
count -= 1
ary[index] = 0
print(index)
|
#!/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 - 1
while any(ary):
count = m
while count:
index = (index+1) % n
if ary[index]:
count -= 1
ary[index] = 0
print(index + 1)
|
[["+", 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 main(String[] args) {
FastScanner sc = new FastScanner();
Scanner stdIn = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
while (sc.hasNext()) {
int[] list = new int[1000];
while (true) {
int a = sc.nextInt();
int b = sc.nextInt();
if (a == 0 && b == 0)
break;
list[a]++;
list[b]++;
}
int e = 0;
int o = 0;
for (int i = 0; i < list.length; i++) {
if (list[i] % 2 == 0) {
e++;
} else {
o++;
}
if (o > 2)
break;
}
out.println((list[1] % 2 == 1 && list[2] % 2 == 1) ? "OK" : "NG");
}
out.flush();
}
}
class LL {
int size;
Node now;
LL(int n) {
now = new Node(null, null, 1);
Node tmp = new Node(null, null, 2);
now.next = tmp;
now.prev = tmp;
tmp.next = now;
tmp.prev = now;
size = n;
now = tmp;
for (int i = 2; i < n; i++) {
add(i + 1);
}
}
void add(int a) {
Node tmp = new Node(null, null, a);
tmp.next = now.next;
tmp.prev = now;
now.next.prev = tmp;
now.next = tmp;
now = tmp;
}
void remove() {
now.prev.next = now.next;
now.next.prev = now.prev;
now = now.next;
size--;
}
}
class Node {
Node next;
Node prev;
int id;
Node(Node a, Node b, int c) {
next = a;
prev = b;
id = c;
}
}
//------------------------------//
//-----------//
class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte())
return buffer[ptr++];
else
return -1;
}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; }
private void skipUnprintable() {
while (hasNextByte() && !isPrintableChar(buffer[ptr]))
ptr++;
}
public boolean hasNext() {
skipUnprintable();
return hasNextByte();
}
public String next() {
if (!hasNext())
throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext())
throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() { return (int)nextLong(); }
}
|
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 main(String[] args) {
FastScanner sc = new FastScanner();
Scanner stdIn = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
while (sc.hasNext()) {
int[] list = new int[1000];
while (true) {
int a = sc.nextInt();
int b = sc.nextInt();
if (a == 0 && b == 0)
break;
list[a]++;
list[b]++;
}
int e = 0;
int o = 0;
for (int i = 0; i < list.length; i++) {
if (list[i] % 2 == 0) {
e++;
} else {
o++;
}
if (o > 2)
break;
}
out.println((list[1] % 2 == 1 && list[2] % 2 == 1 && o == 2) ? "OK"
: "NG");
}
out.flush();
}
}
class LL {
int size;
Node now;
LL(int n) {
now = new Node(null, null, 1);
Node tmp = new Node(null, null, 2);
now.next = tmp;
now.prev = tmp;
tmp.next = now;
tmp.prev = now;
size = n;
now = tmp;
for (int i = 2; i < n; i++) {
add(i + 1);
}
}
void add(int a) {
Node tmp = new Node(null, null, a);
tmp.next = now.next;
tmp.prev = now;
now.next.prev = tmp;
now.next = tmp;
now = tmp;
}
void remove() {
now.prev.next = now.next;
now.next.prev = now.prev;
now = now.next;
size--;
}
}
class Node {
Node next;
Node prev;
int id;
Node(Node a, Node b, int c) {
next = a;
prev = b;
id = c;
}
}
//------------------------------//
//-----------//
class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte())
return buffer[ptr++];
else
return -1;
}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; }
private void skipUnprintable() {
while (hasNextByte() && !isPrintableChar(buffer[ptr]))
ptr++;
}
public boolean hasNext() {
skipUnprintable();
return hasNextByte();
}
public String next() {
if (!hasNext())
throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext())
throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() { return (int)nextLong(); }
}
|
[["+", 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 main(String[] args) {
FastScanner sc = new FastScanner();
Scanner stdIn = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
CON:
while (sc.hasNext()) {
int[] list = new int[1000];
while (true) {
int a = sc.nextInt();
int b = sc.nextInt();
if (a == 0 && b == 0)
break;
list[a]++;
list[b]++;
}
if (list[0] % 2 != 1 || list[1] % 2 != 1) {
out.println("NG");
continue CON;
}
for (int i = 2; i < list.length; i++) {
if (list[i] % 2 == 1) {
out.println("NG");
continue CON;
}
}
out.println("OK");
}
out.flush();
}
}
class LL {
int size;
Node now;
LL(int n) {
now = new Node(null, null, 1);
Node tmp = new Node(null, null, 2);
now.next = tmp;
now.prev = tmp;
tmp.next = now;
tmp.prev = now;
size = n;
now = tmp;
for (int i = 2; i < n; i++) {
add(i + 1);
}
}
void add(int a) {
Node tmp = new Node(null, null, a);
tmp.next = now.next;
tmp.prev = now;
now.next.prev = tmp;
now.next = tmp;
now = tmp;
}
void remove() {
now.prev.next = now.next;
now.next.prev = now.prev;
now = now.next;
size--;
}
}
class Node {
Node next;
Node prev;
int id;
Node(Node a, Node b, int c) {
next = a;
prev = b;
id = c;
}
}
//------------------------------//
//-----------//
class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte())
return buffer[ptr++];
else
return -1;
}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; }
private void skipUnprintable() {
while (hasNextByte() && !isPrintableChar(buffer[ptr]))
ptr++;
}
public boolean hasNext() {
skipUnprintable();
return hasNextByte();
}
public String next() {
if (!hasNext())
throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext())
throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() { return (int)nextLong(); }
}
|
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 main(String[] args) {
FastScanner sc = new FastScanner();
Scanner stdIn = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
CON:
while (sc.hasNext()) {
int[] list = new int[1000];
while (true) {
int a = sc.nextInt();
int b = sc.nextInt();
if (a == 0 && b == 0)
break;
list[a]++;
list[b]++;
}
if (list[1] % 2 != 1 || list[2] % 2 != 1) {
out.println("NG");
continue CON;
}
for (int i = 3; i < list.length; i++) {
if (list[i] % 2 == 1) {
out.println("NG");
continue CON;
}
}
out.println("OK");
}
out.flush();
}
}
class LL {
int size;
Node now;
LL(int n) {
now = new Node(null, null, 1);
Node tmp = new Node(null, null, 2);
now.next = tmp;
now.prev = tmp;
tmp.next = now;
tmp.prev = now;
size = n;
now = tmp;
for (int i = 2; i < n; i++) {
add(i + 1);
}
}
void add(int a) {
Node tmp = new Node(null, null, a);
tmp.next = now.next;
tmp.prev = now;
now.next.prev = tmp;
now.next = tmp;
now = tmp;
}
void remove() {
now.prev.next = now.next;
now.next.prev = now.prev;
now = now.next;
size--;
}
}
class Node {
Node next;
Node prev;
int id;
Node(Node a, Node b, int c) {
next = a;
prev = b;
id = c;
}
}
//------------------------------//
//-----------//
class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte())
return buffer[ptr++];
else
return -1;
}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; }
private void skipUnprintable() {
while (hasNextByte() && !isPrintableChar(buffer[ptr]))
ptr++;
}
public boolean hasNext() {
skipUnprintable();
return hasNextByte();
}
public String next() {
if (!hasNext())
throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext())
throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() { return (int)nextLong(); }
}
|
[["-", 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] = !odd[t];
}
boolean ok = true;
ok &= !odd[1] && !odd[2];
for (int i = 3; i <= 100; i++) {
ok &= odd[i];
}
ln(ok ? "OK" : "NG");
}
}
public static void main(String[] args) { new Main().run(); }
public static void pr(Object o) { System.out.print(o); }
public static void ln(Object o) { System.out.println(o); }
public static void ln() { System.out.println(); }
}
|
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] = !odd[t];
}
boolean ok = true;
ok &= odd[1] && odd[2];
for (int i = 3; i <= 100; i++) {
ok &= !odd[i];
}
ln(ok ? "OK" : "NG");
}
}
public static void main(String[] args) { new Main().run(); }
public static void pr(Object o) { System.out.print(o); }
public static void ln(Object o) { System.out.println(o); }
public static void ln() { System.out.println(); }
}
|
[["-", 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));
while (1) {
if (EOF == scanf("%d %d ", &c1, &c2))
break;
#ifdef DEBUG
printf("%d %d\n", c1, c2);
#endif
if (c1 || c2) {
hist[c1]++;
hist[c2]++;
} else {
ans = 0;
if ((hist[1] & 1) == 0)
ans = 1;
else if ((hist[2] & 1) == 0)
ans = 1;
else
for (i = 3; i < NO_OF_CROSS; i++)
if (hist[i] & 1)
ans = 1;
#ifdef DEBUG
printf("h1234:%d %d %d %d\n", hist[1], hist[2], hist[3], hist[4]);
#endif
printf("%s\n", ans ? "NO" : "YES");
memset(hist, 0, sizeof(hist));
}
}
return (0);
}
|
/*
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));
while (1) {
if (EOF == scanf("%d %d ", &c1, &c2))
break;
#ifdef DEBUG
printf("%d %d\n", c1, c2);
#endif
if (c1 || c2) {
hist[c1]++;
hist[c2]++;
} else {
ans = 0;
if ((hist[1] & 1) == 0)
ans = 1;
else if ((hist[2] & 1) == 0)
ans = 1;
else
for (i = 3; i < NO_OF_CROSS; i++)
if (hist[i] & 1)
ans = 1;
#ifdef DEBUG
printf("h1234:%d %d %d %d\n", hist[1], hist[2], hist[3], hist[4]);
#endif
printf("%s\n", ans ? "NG" : "OK");
memset(hist, 0, sizeof(hist));
}
}
return (0);
}
|
[["-", 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]++;
list[b - 1]++;
}
if (list[0] % 2 == 0 || list[1] % 2 == 0)
flag = true;
for (int i = 2; i < 100; i++) {
if (list[i] % 2)
flag = true;
}
if (!flag)
cout << "OK" << endl;
else
cout << "NG" << endl;
}
return 0;
}
|
#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]++;
list[b - 1]++;
}
flag = false;
if (list[0] % 2 == 0 || list[1] % 2 == 0)
flag = true;
for (int i = 2; i < 100; i++) {
if (list[i] % 2)
flag = true;
}
if (!flag)
cout << "OK" << endl;
else
cout << "NG" << endl;
}
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, 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 = 3; i < 200; i++) {
if (x[i] % 2 == 1)
F = 1;
}
if (x[1] % 2 == 0 || x[2] % 1 == 0)
F = 1;
if (F == 1)
cout << "NG" << endl;
else
cout << "OK" << endl;
}
}
|
#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 = 3; i < 200; i++) {
if (x[i] % 2 == 1)
F = 1;
}
if (x[1] % 2 == 0 || x[2] % 2 == 0)
F = 1;
if (F == 1)
cout << "NG" << endl;
else
cout << "OK" << endl;
}
}
|
[["-", 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 << "NG" << endl;
break;
}
if (i == 100)
cout << "OK" << endl;
else
cout << "NG" << endl;
}
for (int i = 0; i < 100; i++)
hen[i] = 0;
}
}
}
return 0;
}
|
#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 << "NG" << endl;
break;
}
if (i == 100)
cout << "OK" << endl;
}
} else
cout << "NG" << endl;
for (int i = 0; i < 100; i++)
hen[i] = 0;
}
}
return 0;
}
|
[["+", 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;
int sum = 0;
if (dt[1] % 2 == 0 || dt[2] % 2 == 0)
flg = false;
loop(i, 1, 101) if (dt[i] && dt[i] % 2 != 1) flg = false;
cout << ((flg) ? "OK" : "NG") << endl;
}
return 0;
}
|
#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;
int sum = 0;
if (dt[1] % 2 == 0 || dt[2] % 2 == 0)
flg = false;
loop(i, 3, 101) if (dt[i] && dt[i] % 2 == 1) {
flg = false;
break;
}
cout << ((flg) ? "OK" : "NG") << endl;
}
return 0;
}
|
[["-", 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, 64, 9, 0, 46]]
| 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 105
bool check(int M[N]) {
int cnt = 0;
range(i, 3, N) if (M[i] % 2 == 1) return false;
return true;
}
int main() {
int a, b;
while (cin >> a >> b) {
int M[N] = {0};
M[a]++;
M[b]++;
while (cin >> a >> b, a || b) {
M[a]++;
M[b]++;
}
if (check(M)) {
if (M[0] % 2 == 1 && M[1] % 2 == 1)
cout << "OK" << endl;
else
cout << "NG" << endl;
} else
cout << "NG" << endl;
}
}
|
#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 105
bool check(int M[N]) {
int cnt = 0;
range(i, 3, N) if (M[i] % 2 == 1) return false;
return true;
}
int main() {
int a, b;
while (cin >> a >> b) {
int M[N] = {0};
M[a]++;
M[b]++;
while (cin >> a >> b, a || b) {
M[a]++;
M[b]++;
}
if (check(M)) {
if (M[1] % 2 == 1 && M[2] % 2 == 1)
cout << "OK" << endl;
else
cout << "NG" << endl;
} else
cout << "NG" << endl;
}
}
|
[["-", 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;
}
return true;
}
int main() {
while (cin >> a >> b) {
N[a] += 1;
N[b] += 1;
if (a == 0 && b == 0) {
if (ok)
cout << "OK" << endl;
else
cout << "NG" << endl;
for (int i = 0; i < 256; i++)
N[i] = 0;
}
}
return 0;
}
|
#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;
}
return true;
}
int main() {
while (cin >> a >> b) {
N[a] += 1;
N[b] += 1;
if (a == 0 && b == 0) {
if (ok())
cout << "OK" << endl;
else
cout << "NG" << endl;
for (int i = 0; i < 256; i++)
N[i] = 0;
}
}
return 0;
}
|
[["+", 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)
L:
cout << "NG" << endl;
}
}
|
#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)
L:
cout << "NG" << endl;
}
}
|
[["-", 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) {
if (solve())
cout << "OK\n";
else
cout << "NG\n";
for (int i = 1; i <= 100; i++)
map[i] = 0;
continue;
} else {
map[a]++;
map[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) {
if (solve())
cout << "OK\n";
else
cout << "NG\n";
for (int i = 1; i <= 100; i++)
map[i] = 0;
continue;
} else {
map[a]++;
map[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 = false;
}
cout << (f ? "OK" : "NG") << endl;
deg.clear();
}
a--;
b--;
deg[a]++;
deg[b]++;
}
}
|
#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;
}
cout << (f ? "OK" : "NG") << endl;
deg.clear();
continue;
}
a--;
b--;
deg[a]++;
deg[b]++;
}
}
|
[["-", 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 = false;
}
if (a == 0 && b == 0) {
bool ok = true;
for (int i = 0; i < CROSS; i++) {
int num = 0;
for (int j = 0; j < CROSS; j++) {
num += data[i][j];
}
if (i == 1 || i == 2) {
if (num % 2 == 0) {
ok = false;
break;
}
} else {
if (num % 2 != 0) {
ok = false;
break;
}
}
}
if (ok) {
cout << "OK" << endl;
} else {
cout << "NG" << endl;
}
} else {
data[a][b]++;
data[b][a]++;
}
}
}
|
#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 = false;
}
if (a == 0 && b == 0) {
bool ok = true;
for (int i = 0; i < CROSS; i++) {
int num = 0;
for (int j = 0; j < CROSS; j++) {
num += data[i][j];
}
if (i == 1 || i == 2) {
if (num % 2 == 0) {
ok = false;
break;
}
} else {
if (num % 2 != 0) {
ok = false;
break;
}
}
}
if (ok) {
cout << "OK" << endl;
} else {
cout << "NG" << endl;
}
initFlag = true;
} else {
data[a][b]++;
data[b][a]++;
}
}
}
|
[["+", 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)
flag = false;
else if (it->first == 2 && it->second % 2 == 0)
flag = false;
else if (2 < it->first && it->second % 2 == 1) {
flag = false;
break;
}
}
if (flag)
puts("OK");
else
puts("NO");
m.clear();
continue;
}
m[u]++;
m[v]++;
}
return 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)
flag = false;
else if (it->first == 2 && it->second % 2 == 0)
flag = false;
else if (2 < it->first && it->second % 2 == 1) {
flag = false;
break;
}
}
if (flag)
puts("OK");
else
puts("NG");
m.clear();
continue;
}
m[u]++;
m[v]++;
}
return 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 (cin.eof())
goto endrt;
int zz[101] = {0};
int ing = -999, oug;
while (cin >> a >> b) {
if (a == 0 && b == 0)
break;
if (cin.eof())
goto endrt;
zz[a]++;
zz[b]++;
oug = b;
if (ing < 0)
ing = a;
}
bool ans = true;
if (!(zz[ing] % 2 && zz[oug] % 2))
ans = false;
rep(i, 101) if (i != ing && i != oug && zz[i] % 2) ans = false;
// rep(i,101) if(zz[i] > 0){printf("%d:%d, ",i,zz[i]); }
//printf("\n");
if (ing > 0)
cout << (ans ? "YES" : "NO") << endl;
}
endrt:
return 0;
}
|
#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 (cin.eof())
goto endrt;
int zz[101] = {0};
int ing = -999, oug;
while (cin >> a >> b) {
if (a == 0 && b == 0)
break;
if (cin.eof())
goto endrt;
zz[a]++;
zz[b]++;
oug = b;
if (ing < 0)
ing = a;
}
bool ans = true;
if (!(zz[ing] % 2 && zz[oug] % 2))
ans = false;
rep(i, 101) if (i != ing && i != oug && zz[i] % 2) ans = false;
// rep(i,101) if(zz[i] > 0){printf("%d:%d, ",i,zz[i]); }
//printf("\n");
if (ing > 0)
cout << (ans ? "OK" : "NG") << endl;
}
endrt:
return 0;
}
|
[["-", 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; i++)
n[i] = 0;
while (1) {
if (!(cin >> a >> b))
return 0;
if (a + b == 0)
break;
n[a]++;
n[b]++;
}
if (n[1] & 2 != 1 || n[2] != 1)
flg = 1;
for (int i = 3; i <= 100 && flg != 1; i++) {
if (n[i] % 2 == 1)
flg = 1;
}
if (flg == 1) {
cout << "NG" << endl;
} else {
cout << "OK" << endl;
}
}
return 0;
}
|
#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; i++)
n[i] = 0;
while (1) {
if (!(cin >> a >> b))
return 0;
if (a + b == 0)
break;
n[a]++;
n[b]++;
}
if (n[1] % 2 != 1 || n[2] % 2 != 1)
flg = 1;
for (int i = 3; i <= 100 && flg != 1; i++) {
if (n[i] % 2 == 1)
flg = 1;
}
if (flg == 1) {
cout << "NG" << endl;
} else {
cout << "OK" << endl;
}
}
return 0;
}
|
[["-", 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
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.