不知道哪里出错了,求大佬帮个忙看看吧
查看原帖
不知道哪里出错了,求大佬帮个忙看看吧
55227
魂逝_秦月歌楼主2020/11/8 23:50
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <cctype>
#include <queue>
#include <deque>
#include <ctime>
#include <cstring>
#include <string>
#define _e putchar (' ')
#define _v putchar ('\n')
#define ll long long
#define INF 999999999999999999ll
#define INE -999999999999999999ll
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
using namespace std;
inline int lowbit (int x) {
	return x&(-x);
}
inline int mx(int x,int y) {
	return x>y?x:y;
}
inline int mn(int x,int y) {
	return x<y?x:y;
}
inline void r(int &x) {
	int s=0,w=1;
	char ch=getchar ();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar ();}
	while(ch>='0'&&ch<='9') {s=(s<<1)+(s<<3)+(ch^48); ch=getchar ();}
	x=s*w;
}
inline void wr(int x) {
	if(x<0) x=-x,putchar (45);
	if(x<10) {
		putchar (x+48);
		return ;
	}
	wr(x/10);
	putchar (x%10+48);
}
inline int ab (int x) {
	if(x<0) return -x;
	return x;
}
inline void swap (int &x,int &y) {
	x^=y^=x^=y;
}
const int N=205;
int t,q,nowd,nowy,nowm,sum1[N],sum2[N];
const int mon1[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
const int mon2[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool s;
inline bool pd (int x) {
	if(s&&x>1582) {
		if(x%4==0) return 1;
		else return 0;
	}
	if(!s) x--;
	if(x%400==0) return 1;
	if(x%4==0&&x%100!=0) return 1;
	return 0;
}
int main () {
	r(t);
	while (t--) {
		r(q);
		nowd=1,nowm=1,nowy=4713;
		s=0;
		while (q>0) {
			if(pd(nowy)) {
				if(q<=366) {
					if(q-mon1[nowm]>=0) {
						q-=mon1[nowm];
						nowm++;
						nowd=1;
						if(nowm==13) {
							nowm=1;
							if(!s) nowy--;
							else nowy++;
							if(nowy==0) nowy=1,s=1;
						}
					}
					else {
						nowd+=q;
						break;
					}
				}
				else {
					q-=366;
					if(!s) nowy--;
					else nowy++;
					if(nowy==0) nowy=1,s=1;
				}
			}
			else {
				if(q<=365) {
					if(nowy==1582&&nowm==10&&s) {
						if(q<=3) {
							nowd+=q;
							break;
						}
						if(q>3&&q<=mon2[nowm]-10) {
							nowd+=q+10;
							break;;
						}
						if(q>mon2[nowm]-10) {
							nowd=1;
							nowm++;
							q-=(mon2[nowm]-10);
						}
					}
					else {
						if(q-mon2[nowm]>=0) {
							q-=mon2[nowm];
							nowm++;
							nowd=1;
							if(nowm==13) {
								nowm=1;
								if(!s) nowy--;
								else nowy++;
								if(nowy==0) nowy=1,s=1;
							}
						}
						else {
							nowd+=q;
							break;
						}
					}
				}
				else {
					q-=365;
					if(!s) nowy--;
					else nowy++;
					if(nowy==0) nowy=1,s=1;
				}
			}
		}
		wr(nowd),_e,wr(nowm),_e,wr(nowy);
		if(!s) _e,puts("BC");
		else _v;
	}
	return 0;
}



2020/11/8 23:50
加载中...