HPU Fifth annual ACM Competition

Source: Internet
Author: User

VijosP1211 date of birthDescribe

CCC Teacher's birthday is yy years mm month DD Day, he would like to know the date of the 10,000th Day anniversary of his birth (day of birth counted No. 0 day).

Format input Format

Read from the first line of the file into Yy,mm,dd where 1949<=yy<=2006, the date is absolutely legal.

Output format

The output file has only one line, that is, the CCC teacher date after the 10,000th day of birthday, the format is "y-m-d".

Example 1 sample input 1[copy]
1979 4 16
Sample output 1[Copy]
2006-9-1 
: Pit point in, February 29, January 1, December,
Code:
 #include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include < algorithm>using namespace std; #define MEM (x, y) memset (x,y,sizeof (×)) #define YEA (x) (x%400==0| | (x%4==0&&x%100!=0)) int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};int getd (int nn,int yy,int RR) {int d=0;if (yea (NN)) m[2]=29;for (int i =1;i<yy;i++) D+=m[i];d +=rr;m[2]=28;//printf ("%d\n", D); return D;} int main () {int n,nn,yy,rr;while (~scanf ("%d%d%d", &NN,&YY,&RR)) {int d=10000;m[2]=28;if (yea (NN)) d-= (366- GETD (NN,YY,RR)); Else d-= (365-getd (NN,YY,RR)); int Y,mon,r;for (y=nn+1;d>=365;y++) {if (yea (y)) D-=366;else d-=365;} if (yea (y)) m[2]=29;if (d==0) {y--;mon=12;r=31;} else for (mon=1;mon<13;mon++) {if (D>m[mon]) D-=m[mon];else if (D==m[mon]) {r=m[mon];break;} Else{r=d;break;}} printf ("%d-%d-%d\n", Y,mon,r);}
 return 0;} 

HPU Fifth annual ACM competition

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.