20pts求助!
  • 板块P1167 刷题
  • 楼主ljhtomorrow
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/11/25 09:05
  • 上次更新2023/11/25 11:14:22
查看原帖
20pts求助!
1023285
ljhtomorrow楼主2023/11/25 09:05

WhyRE?

#include<bits/stdc++.h>
using namespace std;
int n;
int a[50000];
int jsyear,jsmonth,jsday,jshour,jsmin;
int nowyear,nowmonth,nowday,nowhour,nowmin;
bool check(int x){
	if(((x%4==0&&x%100!=0)||x%400==0))
		return 1;
	else 
		return 0;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	scanf("%d-%d-%d-%d:%d",&nowyear,&nowmonth,&nowday,&nowhour,&nowmin);
	scanf("%d-%d-%d-%d:%d",&jsyear,&jsmonth,&jsday,&jshour,&jsmin);
	sort(a+1,a+1+n);
	int i=1,sum=0;
	while(1){
		sum++;
		nowmin+=a[i];
		if(nowmin>=60){
			nowmin%=60;
			nowhour++;
		}
		if(nowhour>=24){
			nowhour%=24;
			nowday++;
		}
		if((nowmonth==1||nowmonth==3||nowmonth==5||nowmonth==7||nowmonth==8||nowmonth==10||nowmonth==12)&&nowday>=31){
			nowday%=31;
			nowmonth++;
		}
		if((nowmonth==4||nowmonth==6||nowmonth==9||nowmonth==10)&&nowday>=30){
			nowday%=30;
			nowmonth++;
		}
		if(nowmonth==2&&check(nowyear)&&nowday>=29){
			nowday%=29;
			nowmonth++;
		}
		if(nowmonth==2&&!check(nowyear)&&nowday>=28){
			nowday%=28;
			nowmonth++;
		}
		if(nowmonth>=12){
			nowmonth%=12;
			nowyear++;
		}
		if(nowyear>=jsyear&&nowmonth>=jsmonth&&nowday>=jsday&&nowhour>=jshour&&nowmin>=jsmin)
			break;
		i++;
	}
	cout<<sum;
	return 0;
}
2023/11/25 09:05
加载中...