社区讨论

20pts求助!

P1167刷题参与者 1已保存回复 0

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
0 条
当前快照
1 份
快照标识符
@lpdcq3q1
此快照首次捕获于
2023/11/25 09:07
2 年前
此快照最后确认于
2023/11/25 11:14
2 年前
查看原帖

WhyRE?

CPP
#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;
}

回复

0 条回复,欢迎继续交流。

正在加载回复...