记得当时在考场上测的都没问题的,但自己测就的月老是输出0(调试发现yue是对的,但就是输出0……)
#include<iostream>
#include<cstdio>
using namespace std;
long long x;
int mon[15]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int year[500]={0,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,365,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,365,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,365,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365,366,365,365,365};
void play()
{
long long nian,ri,yue,i;
bool pp=false;
if(x<=2299161)//前历
{
nian=-4712,ri=1,yue=1;
nian+=x/1461ll*4ll;
x%=1461;//四年
pp=true;
if(x>=366) nian++,x-=366ll,pp=false;
if(x>=365) nian++,x-=365ll;
if(x>=365) nian++,x-=365ll;
i=1;
if(pp) mon[2]++;
while(x)
{
if(x<mon[i]) ri+=x,x=0;
else x-=mon[i],yue++,i++;
}
if(pp) mon[2]--;
printf("%d %d ",ri,yue);
if(nian<=0)
{
nian=1-nian;
printf("%d BC\n",nian);
}
else printf("%d\n",nian);
}
else//公历
{
x-=2299161ll;
nian=1582,ri=15,yue=10;
if(x<=16) ri+=x,x=0;//10月
else yue=11,ri=1,x-=17;
if(x<30) ri+=x,x=0;//11月
else yue=12,x-=30;
if(x<31) ri+=x,x=0;//12月
else yue=1,nian++,x-=31;
nian+=x/146097*400ll;
x%=146097;
i=1;
while(x>=year[i]) x-=year[i],i++,nian++;
if(year[i]==366) pp=true;
if(pp) mon[2]++;
i=1;
while(x)
{
if(x<mon[i]) ri+=x,x=0;
else x-=mon[i],yue++,i++;
}
if(pp) mon[2]--;
printf("%d %d %d\n",ri,yue,nian);
}
}
int main()
{
freopen("julian.in","r",stdin);
freopen("julian.out","w",stdout);
int n;
cin>>n;
while(n--)
{
cin>>x;
play();
}
fclose(stdin);
fclose(stdout);
return 0;
}