日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

第十届四川省大学生程序设计竞赛

發(fā)布時(shí)間:2024/10/6 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 第十届四川省大学生程序设计竞赛 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

點(diǎn)擊打開鏈接

E: Ever17

Time Limit: 1000 MS Memory Limit: 1048576 KB
Total Submit: 196 Accepted: 39 Page View: 573
Submit Status Clarify

Description

As is known to all, we have two formats to denote a specific date: MM/DD/YY or YY/MM/DD. We supposed the years discussed below are years in 20YY.

Now you are given a string representing the date. If there is only one possible date it can fit in with format of "MM/DD/YY" or "YY/MM/DD", output the date in the format of "month date, year" (as can be seen in the second sample). Otherwise, output the days between the two different dates it might be.

Input

The first line contains an integer Trepresenting the number of test cases. In each test case, a string ”AA/BB/CC” is given in one line. It is guaranteed that there is at least one legal date it can fit in with
format of ”MM/DD/YY” or ”YY/MM/DD”.1T5

Output

For each test case, if there are two different possible dates, output an integer in one line representing the days between the two possible dates. In the other case, output the exact date in one line. 302/07/1919/02/0707/02/19 6047February 7, 20194516

Hint

In the first sample, the date might be July 19th, 2002 or February 7th, 2019. The number of days between the two dates are 6047 days.As for the second sample, the only possible date is February 7th, 2019.There are 12 months in a year and they are January, February, March, April, May, June, July, August, September, October, November and December.Also, please note that there are 29 days in February in a leap year while 28 days in nonleap year.


題意:

給一個(gè)合法的日期,可能是MM/DD/YY or YY/MM/DD,如果是其中的一種,則輸出"month date, year",

否則,輸出兩個(gè)日期的差值,若差值為0,輸出個(gè)日期

Otherwise, output the days between the two different dates it might be.

#include<bits/stdc++.h> using namespace std; int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int leap_day[13]={0,31,29,31,30,31,30,31,31,30,31,30,31}; char month[13][10]={"","January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November" ,"December"}; bool leap(int y) {if(y%4==0&&y%100!=0||y%400==0)return 1;return 0; } bool check(int y,int m,int d) {if(y<0||y>99) return 0;if(m<1||m>12) return 0;if(d<1||d>31) return 0;if(leap(y+2000)){if(d>leap_day[m]) return 0;}elseif(d>day[m]) return 0;return 1; } long long sum(int y,int m,int d) {long long sum=0;for(int i=0;i<y;i++){if(leap(i+2000))sum+=366;elsesum+=365;}if(leap(y+2000)){for(int i=1;i<m;i++)sum+=leap_day[i];}else{for(int i=1;i<m;i++)sum+=day[i];}sum+=d;return sum; } void print(int y,int m,int d) {printf("%s %d, %d\n",month[m],d,y+2000); } int main() {int t;int a,b,c;scanf("%d",&t);while(t--){scanf("%d/%d/%d",&a,&b,&c);bool s1=check(c,a,b),s2=check(a,b,c);if(s1&&!s2) print(c,a,b);if(!s1&&s2) print(a,b,c);if(s1&&s2)//兩種情況下都合法if(abs(sum(c,a,b)-sum(a,b,c)))//差值不為0printf("%lld\n",abs(sum(c,a,b)-sum(a,b,c)));else//輸出一個(gè)日期//print(a,b,c);print(c,a,b);}return 0; }



總結(jié)

以上是生活随笔為你收集整理的第十届四川省大学生程序设计竞赛的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。