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