1 条题解
-
1
#include<bits/stdc++.h> #define ll long long #define int long long //重要 #define gc getchar using namespace std; inline ll read(){ ll x=0,f=1;char ch=gc(); while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();} while (isdigit(ch)){x=x10ll+ch-'0';ch=gc();} return xf; } const int mon[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; const int rmon[13]={0,31,29,31,30,31,30,31,31,30,31,30,31}; struct que{ int t,id; }q[1010101]; struct QWQ{ int y,m,d; }ori,tmp,ans[101010],X[300001]; int Q,mx,cnt; inline bool cmp(que a,que b){return a.t<b.t;} inline int mabs(int x){return (x>0?x:-x);} inline bool isr(QWQ a){ if (a.y<0) return (-a.y-1)%40; if (a.y>=1582) return a.y%4000||(a.y%40&&a.y%100); if (a.y%40) return 1; return 0; } inline QWQ nextday(QWQ a){ //分类讨论 QWQ ans=a; if (a.y1582){ if (a.m12&&a.d31) ans.y++,ans.d=1,ans.m=1; else if (a.m10&&a.d4) ans.d=15; else if (a.dmon[a.m]) ans.d=1,ans.m++; else ans.d++; return ans; } if (a.y==-1&&a.m12&&a.d31) ans.y=1,ans.d=1,ans.m=1;
else if (isr(a)){ if (a.m12&&a.d31) ans.y++,ans.d=1,ans.m=1; else if (a.drmon[a.m]) ans.d=1,ans.m++; else ans.d++; }else{ if (a.m12&&a.d31) ans.y++,ans.d=1,ans.m=1; else if (a.dmon[a.m]) ans.d=1,ans.m++; else ans.d++; } return ans; } signed main(){ ori.y=-4713,ori.m=1,ori.d=1,cnt=-1; Q=read(); for (int i=1;i<=Q;i++) q[i].id=i,q[i].t=read(); sort(q+1,q+1+Q,cmp); tmp=ori; for (int i=1;i<=Q;i++){ if (q[i].t>=2451545) break; mx=i; } for (int i=1,now=0;i<=mx;i++){ for (;now!=q[i].t;now++) tmp=nextday(tmp); ans[q[i].id]=tmp; } tmp.d=1,tmp.m=1,tmp.y=2000; for (;tmp.y!=2400;) X[++cnt]=tmp,tmp=nextday(tmp); for (int i=mx+1;i<=Q;i++){ ans[q[i].id].d=X[(q[i].t-2451545)%146097].d; ans[q[i].id].m=X[(q[i].t-2451545)%146097].m; ans[q[i].id].y=X[(q[i].t-2451545)%146097].y+400*((q[i].t-2451545)/146097); } for (int i=1;i<=Q;i++){ printf("%lld %lld %lld",ans[i].d,ans[i].m,mabs(ans[i].y)); if (ans[i].y<0) printf(" BC"); puts(""); } return 0; }
- 1
信息
- ID
- 316
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 6
- 标签
- 递交数
- 63
- 已通过
- 18
- 上传者