【找了好久都没找出问题】样例二未过 求大犇指点
查看原帖
【找了好久都没找出问题】样例二未过 求大犇指点
376970
fishPJ楼主2022/10/7 22:19

【找了好久都没找出问题】样例二未过 求大犇指点

#include <bits/stdc++.h>
#define f(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;
int const D[13]={0,31,30,31,30,31,30,31,31,30,31,30,31};
int const DAY=86400,HOUR=3600,MIN=60;
bool rn(int y){
	if(y%4==0) return 1;
	if(y%100==0 && y%400!=0) return 0;
	if(y%400==0) return 1;
	return 0;
}
int T;
struct node{
	int len,year,mth,day,hour,min,sec;
	void scan(){
		cin>>len>>year>>mth>>day>>hour>>min>>sec;
	}
	void print(){
		cout<<year<<' '<<mth<<' '<<day<<' '<<hour<<' '<<min<<' '<<sec<<endl;
	}
	void update(){
		if(sec>=60) min++,sec%=60;
		if(min>=60) hour++,min%=60;
		if(hour>=24) day++,hour%=24;
		int k=D[mth];
		if(mth==2 && rn(year)) k++;
		if(day>=k) mth++,day-=k;
		if(mth>=12) year++,mth%=12;
	}
}st,a;
int main() {
	ios::sync_with_stdio(false);
	cin>>T;
	while(T--){
		st.scan(); a=st;
		long long change=(1<<(st.len-1))-1,ud=0;
		cout<<change<<endl;
		while(ud+DAY<=change){
			ud+=DAY;
			a.day++;
			a.update();
//			cout<<a.day<<' '<<ud<<endl;
		}
		while(ud+HOUR<=change){
			ud+=HOUR;
			a.hour++;
			a.update();
//			cout<<a.hour<<' '<<ud<<endl;
		}
		while(ud+MIN<=change){
			ud+=MIN;
			a.min++;
			a.update();
//			cout<<a.min<<' '<<ud<<endl;
		}
		while(ud<change){
			ud++;
			a.sec++;
			a.update();
//			cout<<a.sec<<' '<<ud<<endl;
		}
		a.print();
	}
	return 0;
}
2022/10/7 22:19
加载中...