这道题其实打表就可以过了,一点细节都没有,非常无脑
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
inline void read(int &x) {
x = 0; int f = 0; char s = getchar();
while (s < '0' || '9' < s) f |= s == '-', s = getchar();
while ('0' <= s && s <= '9') x = x * 10 + s - 48, s = getchar();
x = f ? -x : x;
}
int day[2][13] = {{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
const int N = 2459520, M = 147132;
int x[N], y[N], z[N], x1[M], ____[M], z1[M];
bool rn(int ty) {
if (ty < 0) {
if ((ty + 1) % 4 == 0) return 1;
return 0;
}
else if (ty < 1584) {
if (ty % 4 == 0) return 1;
return 0;
}
else if (ty % 400 == 0 || (ty % 4 == 0 && ty % 100 != 0)) return 1;
return 0;
}
int main() {
// freopen("julian.in", "r", stdin);
// freopen("julian.out", "w",stdout);
// rn(2100);
int i = 1;
for (int xx = -4713, yy = 1, zz = 1;; i++) {
if (xx == 2000) break;
x[i] = xx, y[i] = yy, z[i] = zz;
zz++;
if (zz == day[rn(xx)][yy] + 1) {
zz = 1;
yy++;
}
if (yy == 13) yy = 1, xx++;
if (xx == 0) xx = 1;
if (xx == 1582 && yy == 10 && zz == 5) zz = 15;
}
int fg = i - 1;
i = 0;
for (int xx = 0, yy = 1, zz = 1;; i++) {
if (xx == 400) break;
x1[i] = xx, ____[i] = yy, z1[i] = zz;
zz++;
if (zz == day[rn(2000 + xx)][yy] + 1) {
zz = 1;
yy++;
}
if (yy == 13) yy = 1, xx++;
}
int zq = i;
int tt; cin >> tt;
while (tt--) {
long long td; scanf("%lld", &td); td++;
if (td <= fg) {
if (x[td] < 0)
printf("%d %d %d BC\n", z[td], y[td], -x[td]);
else
printf("%d %d %d\n", z[td], y[td], x[td]);
}
else {
td -= fg + 1;
int ha = td % zq, per = td / zq;
printf("%d %d %d\n", z1[ha], ____[ha], 2000 + 400 * per + x1[ha]);
}
}
return 0;
}