日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發(fā)布時間:2024/10/6 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 第十届四川省大学生程序设计竞赛 小編覺得挺不錯的,現(xià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.


題意:

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

否則,輸出兩個日期的差值,若差值為0,輸出個日期

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//輸出一個日期//print(a,b,c);print(c,a,b);}return 0; }



總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。