记录编号 |
581360 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[CSP 2020S]儒略日 |
最终得分 |
100 |
用户昵称 |
┭┮﹏┭┮ |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.153 s |
提交时间 |
2023-08-01 22:45:01 |
内存使用 |
2.87 MiB |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll s;
ll p[20] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
ll r[20] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
ll x1 = 1721424,x2 = 2299161;
ll chu(ll x,ll y){
if(x % y == 0)return (x / y) - 1;
return x / y;
};
ll mo(ll x,ll y){
if(x % y == 0)return y;
return x % y;
}
void BC();
void BC_();
int main(){
freopen("2020julian.in","r",stdin);
freopen("2020julian.out","w",stdout);
for(int i = 1;i <= 12;i++){
p[i] += p[i-1];
r[i] += r[i-1];
}
scanf("%d",&n);
for(ll j = 1;j <= n;j++){
scanf("%lld",&s);
s++;
//cout<<s<<endl;
if(s <= x1){
BC();
continue;
}
else if(s <= x2){
BC_();
continue;
}//消失の10天
else{
s = s - x2 + 277 + 10;//加上消失の10天
if(s <= 730){
ll year = chu(s,365),day = mo(s,365);
for(int i = 1;i <= 12;i++){
if(day <= p[i]){
printf("%d %d %d\n",day-p[i-1],i,1582+year);
break;
}
}
continue;
}
else if(s <= 6574){
s -= 730;
ll year4 = chu(s,1461),day = mo(s,1461);
if(day <= 366){
for(int i = 1;i <= 12;i++)
if(day <= r[i]){
printf("%d %d %d\n",day-r[i-1],i,1584+4*year4);
break;
}
}
else{
ll year1 = chu(day-366,365);day = mo(day-366,365);
for(int i = 1;i <= 12;i++){
if(day <= p[i]){
printf("%d %d %d\n",day-p[i-1],i,1584+4*year4+year1+1);
break;
}
}
}
}
else if(s <= 6940){
s -= 6574;
for(int i = 1;i <= 12;i++){
if(s <= r[i]){
printf("%d %d 1600\n",s-r[i-1],i);
break;
}
}
}
else{
s -= 6940;
ll year400 = chu(s,146097),day = mo(s,146097);
if(day <= 109572){//前三百年
ll year100 = chu(day,36524);day = mo(day,36524);
if(day <= 35064){
ll year4 = chu(day,1461);day = mo(day,1461);
if(day <= 1095){
ll year = chu(day,365);day = mo(day,365);
for(int i = 1;i <= 12;i++){
if(day <= p[i]){
printf("%d %d %d\n",day-p[i-1],i,1600+year400*400+year100*100+year4*4+year+1);
break;
}
}
}
else{
day -= 1095;
for(int i = 1;i <= 12;i++){
if(day <= r[i]){
printf("%d %d %d\n",day-r[i-1],i,1600+year400*400+year100*100+year4*4+4);
break;
}
}
}
}
else{
day -= 35064;
ll year = chu(day,365);day = mo(day,365);
for(int i = 1;i <= 12;i++){
if(day <= p[i]){
printf("%d %d %d\n",day-p[i-1],i,1696+year400*400+year100*100+year+1);
break;
}
}
}
}
else{//后一百年
day -= 109572;
ll year4 = chu(day,1461);day = mo(day,1461);
if(day <= 1095){
ll year = chu(day,365);day = mo(day,365);
for(int i = 1;i <= 12;i++){
if(day <= p[i]){
printf("%d %d %d\n",day-p[i-1],i,1600+400*year400+300+4*year4+year+1);
break;
}
}
}
else{
day -= 1095;
for(int i = 1;i <= 12;i++){
if(day <= r[i]){
printf("%d %d %d\n",day-r[i-1],i,1600+400*year400+300+4*year4+4);
break;
}
}
}
}
}
}
}
return 0;
}
void BC_(){
ll year4 = chu(s-x1,1461),day = mo(s-x1,1461);
if(day <= 1095){
ll year = chu(day,365);day = mo(day,365);
for(int i = 1;i <= 12;i++){
if(day <= p[i]){
printf("%d %d %d\n",day-p[i-1],i,year4*4+year+1);
break;
}
}
}
else{
day -= 1095;
for(int i = 1;i <= 12;i++){
if(day <= r[i]){
printf("%d %d %d\n",day-r[i-1],i,year4*4+4);
break;
}
}
}
return;
}
void BC(){
ll year = chu(s,1461),day = mo(s,1461);
if(day <= 366){
for(int i = 1;i <= 12;i++)
if(day <= r[i]){
printf("%d %d %d BC\n",day-r[i-1],i,4713-4*year);
break;
}
}
else{
ll year1 = chu(day-366,365);day = mo(day-366,365);
for(int i = 1;i <= 12;i++){
if(day <= p[i]){
printf("%d %d %d BC\n",day-p[i-1],i,4713-4*year-(year1+1));
break;
}
}
}
return;
}