Vigorously mock questions
Because I’m too veteran, when I took the exam, I forced it out every day from 4713 BC to 1583 in the park. It was about 2 ⋅ 1 0 6 2 \cdot 10^62⋅106 days. If it is out of the range, take a modulus, and you will be done after a few more special judgments.
The result was a large sample/jk in 40 minutes
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const long long Maxn=3600000+10;
const long long d1[]={
0,31,28,31,30,31,30,31,31,30,31,30,31};
const long long d2[]={
0,31,29,31,30,31,30,31,31,30,31,30,31};
struct node{
long long x,y,z;
}g[Maxn];
long long n,k,m,q;
inline long long read()
{
long long s=0,w=1;
char ch=getchar();
while(ch<'0' || ch>'9'){
if(ch=='-')w=-1;ch=getchar();}
while(ch>='0' && ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
return s*w;
}
int main()
{
// freopen("julian.in","r",stdin);
// freopen("julian.out","w",stdout);
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
g[0].x=g[0].y=1;
g[0].z=4713;
while(!(g[n].x==31 && g[n].y==12 && g[n].z==1))
{
++n;
g[n].x=g[n-1].x+1;
g[n].y=g[n-1].y;
g[n].z=g[n-1].z;
long long tmp;
if(g[n].z%4==1)tmp=d2[g[n].y];
else tmp=d1[g[n].y];
if(g[n].x>tmp)++g[n].y,g[n].x=1;
if(g[n].y>12)g[n].y=1,g[n].z--;
}
k=n;
++n;
g[n].x=g[n].y=g[n].z=1;
while(!(g[n].x==4 && g[n].y==10 && g[n].z==1582))
{
++n;
g[n].x=g[n-1].x+1;
g[n].y=g[n-1].y;
g[n].z=g[n-1].z;
long long tmp;
if(g[n].z%4==0)tmp=d2[g[n].y];
else tmp=d1[g[n].y];
// if(g[n].z%400==0 || (g[n].z%4==0 && g[n].z%100))
// tmp=d2[g[n].y];
// else tmp=d1[g[n].y];
if(g[n].x>tmp)++g[n].y,g[n].x=1;
if(g[n].y>12)g[n].y=1,g[n].z++;
}
++n;
g[n].x=15,g[n].y=10,g[n].z=1582;
while(!(g[n].x==31 && g[n].y==12 && g[n].z==1582))
{
++n;
g[n].x=g[n-1].x+1;
g[n].y=g[n-1].y;
g[n].z=g[n-1].z;
long long tmp;
if(g[n].z%400==0 || (g[n].z%4==0 && g[n].z%100))
tmp=d2[g[n].y];
else tmp=d1[g[n].y];
if(g[n].x>tmp)++g[n].y,g[n].x=1;
if(g[n].y>12)g[n].y=1,g[n].z++;
}
//1583
m=n,++n;
g[n].x=g[n].y=1,g[n].z=1583;
while(!(g[n].x==31 && g[n].y==12 && g[n].z==1982))
{
++n;
g[n].x=g[n-1].x+1;
g[n].y=g[n-1].y;
g[n].z=g[n-1].z;
long long tmp;
if(g[n].z%400==0 || (g[n].z%4==0 && g[n].z%100))
tmp=d2[g[n].y];
else tmp=d1[g[n].y];
if(g[n].x>tmp)++g[n].y,g[n].x=1;
if(g[n].y>12)g[n].y=1,g[n].z++;
}
q=read();
while(q--)
{
long long tmp=read();
if(tmp<=k)
{
printf("%lld %lld %lld BC\n",g[tmp].x,g[tmp].y,g[tmp].z);
continue;
}
if(tmp<=m)
{
printf("%lld %lld %lld\n",g[tmp].x,g[tmp].y,g[tmp].z);
continue;
}
// 400 years = 146097 days
tmp-=m;
long long cur=tmp/146097ll;
cur*=400ll;
tmp%=146097ll;
tmp+=m;
printf("%lld %lld %lld\n",g[tmp].x,g[tmp].y,g[tmp].z+cur);
}
// printf("%lld %lld %lld\n",k,m,n);
return 0;
}