首页 > 其他分享 >[挑战记录]儒略历

[挑战记录]儒略历

时间:2022-10-02 18:22:16浏览次数:43  
标签:记录 ++ 挑战 int lunar year 366 365 儒略历

两年前就差点切掉,现在终于切了
没什么好说的,就是用计算器进行手算年份

#include<cstdio>
#include<cstring>
#include<string>
#define WR WinterRain
#define int long long
using namespace std;
const int WR=1001000;
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int q,n;
int lunar_sum;
int read(){
    int s=0,w=1;
    char ch=getchar();
    while(ch>'9'||ch<'0'){
        if(ch=='-') w=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        s=(s<<3)+(s<<1)+ch-'0';
        ch=getchar();
    }
    return s*w;
}
void count_julian(int year,int k,bool lunar){
    if(lunar) month[2]++;
    int tot=0,mth;
    for(int i=1;i<=12;i++){
        tot+=month[i];
        if(tot>=k){
            mth=i;
            k-=(tot-month[i]);
            if(year-4713<0) printf("%lld %lld %lld BC\n",k,mth,4713-year);
            else printf("%lld %lld %lld\n",k,mth,year-4712);
            break;
        }
    }
    if(lunar) month[2]--;
}
void count_gregory(int year,int k,bool lunar){
    if(lunar) month[2]++;
    int tot=0,mth;
    bool flag=false;
    for(int i=1;i<=12;i++){
        tot+=month[i];
        if(tot>=k){
            mth=i;
            k-=(tot-month[i]);
            printf("%lld %lld %lld\n",k,mth,year+1600);
            flag=true;
            break;
        }
    }
    if(!flag) printf("1 1 %lld\n",year+1601);
    if(lunar) month[2]--;
}
signed main(){
    freopen("julian.in","r",stdin);
    freopen("julian.out","w",stdout);
    for(int i=1;i<=400;i++){
        if((i%4==0&&i%100!=0)||i%400==0) lunar_sum++;
    }
    q=read();
    while(q--){
        n=read();
        if(n<=2299160){
            int k=n%(365*4+1),year=n/(365*4+1)*4;
            bool lunar=true;
            if(k>=366) k-=365,year++,lunar=false;
            if(k>=366) k-=365,year++;
            if(k>=366) k-=365,year++;
            if(lunar==1) k++;
            count_julian(year,k,lunar);
        }else{
            n+=10;
            if(n<=2305457){
                int k=n%(365*4+1),year=n/(365*4+1)*4;
                bool lunar=true;
                if(k>=366) k-=365,year++,lunar=false;
                if(k>=366) k-=365,year++;
                if(k>=366) k-=365,year++;
                if(lunar==1) k++;
                count_julian(year,k,lunar);
            }else{
                n-=2305458;
                int k=n%(365*400+lunar_sum),year=n/(365*400+lunar_sum)*400;
                bool lunar=true;
                if(k>=366) k-=365,year++,lunar=false;
                for(int i=2;i<=399;i++){
                    if(i%4==0&&i%100!=0){
                        if(k>=367) k-=366,year++,lunar=true;
                        else break;
                    }
                    else{
                        if(k>=366) k-=365,year++,lunar=false;
                        else break;
                    }
                }
                if(lunar) k++;
                count_gregory(year,k,lunar);
            }
        }
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}

标签:记录,++,挑战,int,lunar,year,366,365,儒略历
From: https://www.cnblogs.com/WintersRain/p/16749183.html

相关文章

  • 学习记录13标准的JavaBean类
    标准的JavaBean类类名需要见名知意成员变量使用private修饰提供至少两个构造方法无参构造方法带全部参数的构造方法成员方法提供每一个成员变量对应的setXxx()......
  • AutoDL安装记录
    (可以不配置自己的基础环境即只使用安装pytorch版本的一个步骤,但是PyTorch中torch、torchvision、torchaudio、CUDA 版本的关系必须对应,否则gpu不运行。) 点击终端输......
  • 【博学谷学习记录】超强总结,用心分享|Java基础分享-Redis基础简介
    1.1Redis简介1.2Redis资料1.2.1初步教程1.2.2其他教程2.1做为数据库与之比较2.2做为高速缓存与之比较2.3做为消息队列与之比较一、Redis基础知识1.1Redis......
  • DASCTF-X-CBCTF-2022九月挑战赛-md
    title:DASCTF-X-CBCTF-2022几月挑战赛.mddate:2022-09-1820:24:51tags:DASCTFXCBCTF2022九月挑战赛3d小恐龙这道题经过队友的提示才做出来的。。。。。不......
  • 【博学谷学习记录】超强总结,用心分享|Linux修改文件权限方法总结
    一、介绍linux中“一切皆文件”。每个文件都设定了针对不同用户的访问权限。文件权限主要针对以下三种对象:属主:拥有者属组:所属的组其他人:不属于上述两类二、文件权限......
  • 命但如通知,但客户终每条记录能件,转换成
    命但如通知,但客户终每条记录能件,转换成F潞}命但如通知,但客户终每条记录能件,转换成m命但如通知,但客户终每条记录能件,转换成http://ds.163.com/article/63371fb8880c710001935......
  • ROS-MoveIt学习记录
    教程古月居:7ROS理论与实践_.Moveit!机械臂控制_视频_哔哩哔哩_bilibili对应源码:Whiffe/arm-of-robot-using-Moveit-in-ros-gazebo-rviz(github.com)问题ImportErr......
  • 十月做题记录
    10月1日CF54C\(CF54CFirstDigitLaw\)\(Solution:\)概率\(DP\)+期望\(DP\)。由简单数位\(DP\)可得到第\(i\)个数为\(1\)开头的概率。设\(f[i][j]\)表示前......
  • C++_Windows Socket 学习记录_01
    主要实现服务器-服务器传输消息Server.cpp#include<stdio.h>#include<stdlib.h>#include<WinSock2.h>#include<iostream>#pragmacomment(lib,"ws2_32.lib")us......
  • WVP ZLMediaKit搭建记录
    ZLMediaKit地址:https://github.com/ZLMediaKit/ZLMediaKitWVP地址:https://github.com/648540858/wvp-GB28181-pro ZLMediaKit开启SSL1.查看ZLMediaKit配置文件中的SSL......