记录编号 |
557588 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[CSP 2020S]儒略日 |
最终得分 |
100 |
用户昵称 |
锝镆氪锂铽 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.241 s |
提交时间 |
2020-11-18 21:13:21 |
内存使用 |
6.83 MiB |
显示代码纯文本
#include <cstdio>
#include <iostream>
using namespace std;
const int julian = 2299162;
int Month(), Monthr();
long long q, r, day, month, year;
int months[15] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int monthr[15] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main(){
freopen("2020julian.in", "r", stdin);
freopen("2020julian.out", "w", stdout);
scanf("%lld", &q);
for(int asdf = 0; asdf < q; asdf ++){
scanf("%lld", &r);
r ++;
if (r < julian){
year = (r / 1461) * 4;
r %= 1461;
if (r <= 59){
month = r > 31 ? 2 : 1;
day = r > 31 ? r - 31 : r;
}
else{
if (r <= 366){
month = Monthr();
day = r;
}
else{
year += (r - 366) / 365 + 1;
r -= 366, r %= 365;
month = Month();
day = r;
}
}
if (year < 4713)
if (day == 0 && month == 1)
printf("31 12 %lld BC\n", 4713 - year + 1);
else
printf("%lld %lld %lld BC\n", day, month, 4713 - year);
else
if (day == 0 && month == 1)
printf("31 12 %lld\n", year - 4713);
else
printf("%lld %lld %lld\n", day, month, year - 4713 + 1);
}
else{
r -= julian;
year = 1582;
if (r <= 77){
if (r <= 16)
month = 10, day = 15 + r;
else if (r <= 46)
month = 11, day = r - 16;
else
month = 12, day = r - 46;
}
else {
r -= 77;
if (r <= 365){
year ++;
month = Month();
day = r;
}
else{
r -= 365;
year = 1584;
if (r <= 5844){
year += (r / 1461) * 4;
r %= 1461;
if (r <= 366){
month = Monthr();
day = r;
}
else {
r -= 366;
year ++;
year += r / 365;
r %= 365;
month = Month();
day = r;
}
}
else{
r -= 5844;
year = 1600;
year += (r / 146097) * 400;
r %= 146097;
if (r <= 36525){
year += (r / 1461) * 4;
r %= 1461;
if (r <= 366)
month = Monthr(), day = r;
else{
r -= 366;
year ++;
year += r / 365;
r %= 365;
month = Month();
day = r;
}
}
else{
r -= 36525;
year += 100;
year += (r / 36524) * 100;
r %= 36524;
if (r <= 1460){
year += r / 365;
r %= 365;
month = Month();
day = r;
}
else{
r -= 1460;
year += 4;
year += (r / 1461) * 4;
r %= 1461;
if (r <= 366)
month = Monthr(), day = r;
else{
r -= 366;
year ++;
year += r / 365;
r %= 365;
month = Month();
day = r;
}
}
}
}
}
}
if (day == 0 && month == 1)
printf("31 12 %lld\n", year - 1);
else
printf("%lld %lld %lld\n", day, month, year);
}
}
return 0;
}
int Month(){
int i;
for (i = 0; i < 12; i ++){
if (r > months[i])
r -= months[i];
else
break;
}
return i + 1;
}
int Monthr(){
int i;
for (i = 0; i < 12; i ++){
if (r > monthr[i])
r -= monthr[i];
else
break;
}
return i + 1;
}