TG T1求助
  • 板块灌水区
  • 楼主Archers_wylr
  • 当前回复0
  • 已保存回复0
  • 发布时间2020/11/9 20:41
  • 上次更新2023/11/5 08:22:01
查看原帖
TG T1求助
209186
Archers_wylr楼主2020/11/9 20:41

代码如下,求hack数据或者大佬帮忙查错orz

#include<bits/stdc++.h>
using namespace std;
long long n,x;
int sum1[13]={0,31,59,90,120,151,181,212,243,273,304,334,365};//平年前i个月的总天数为sum1[i]; 
int sum2[13]={0,31,60,91,121,152,182,213,244,274,305,335,366};//闰年前i个月的总天数为sum2[i];
//priority_queue<int, vector<int>,greater<int> >q;
int ideg(int x){
	int ans;
	x/=100;
	x-=15;
	if(x%4==0) ans=x/4;
	else ans=x/4+1;
	return x-ans;
}
void work(long long x,int k,int yea,int f){//k:1 run 0 ping
	int s,m; 
	if(yea>=1600&&f==1){
			int u=ideg(yea);
			if(yea%100==0&&yea%400!=0){
				x+=u;
				x--;
				k=0;	
			}
			else x+=u; 
			if(k==1){
				int aa=x/1461;
				yea+=4*aa;
				x%=1461;
				if(x>=366){
					x-=366,yea++;
					while(x>=365){
					x-=365;
					yea++;
					}
				}
			}
			if(k==0){
				int q=yea%4;
				for(int i=1;i<=4-q;i++){
					if(x>=365)x-=365,yea++;
				}
				int aa=x/1461;
				yea+=4*aa;
				x%=1461;
				if(x>=366){
					x-=366,yea++;
					while(x>=365){
					x-=365;
					yea++;
					}
				}
			}
		}
	if(k==1){
		s=upper_bound(sum2+1,sum2+13,x)-sum2;
		m=sum2[s]-sum2[s-1]-sum2[s]+x+1;
	}
	if(k==0){
		s=upper_bound(sum1+1,sum1+13,x)-sum1;
		m=sum1[s]-sum1[s-1]-sum1[s]+x+1;
	}
	if(yea==0)yea++,f=1;
	if(f==0)cout<<m<<" "<<s<<" "<<yea<<" BC"<<endl;
	else {
		cout<<m<<" "<<s<<" "<<yea<<endl;
	}
}
void workk(int x,int q){
	int a=x/1461;
	int year=4713-4*a;
	x-=1461*a;
	if(year<=0){
			year=-year;
			year++;
			if(x>=366){
			x-=366,year++;
			while(x>=365){
				x-=365;
				year++;
			}
		}
		if(year%4==0)work(x,1,year,1);
		else work(x,0,year,1);
		return;
	}
	if(x>=366){
		x-=366,year--;
		while(x>=365){
			x-=365;
			year--;
		}
	}
//	cout<<x<<endl;
	if(year<=0){
		year=-year;
		year++;
		if(year%4==0)work(x,1,year,1);
		else work(x,0,year,1);
		return;
	}
	int year1=year-1;
	if(q==0){
		if(year1%4==0)work(x,1,year,0);
		else work(x,0,year,0);			
	}
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(x==366)cout<<"1 1 4712 BC"<<endl;
		if(x<366)work(x,1,4713,0);
		if(x>366&&x<2299161)workk(x,0);
		if(x==2299162)cout<<"15 11 1582"<<endl;
		if(x>=2299163&&x<=2299240)workk(x+10,0);
		if(x>2299240)workk(x+10,1);
	}
	return 0;
}
2020/11/9 20:41
加载中...