HDU1201+简单题
简单题。
明白闰年是什么。。
View Code
1 /* 2 简单题 3 闰年的判断: 4 year%4==0&&(year%100!=0||year%400==0) 5 */ 6 #include<stdio.h> 7 #include<string.h> 8 #include<stdlib.h> 9 #include<iostream> 10 #include<queue> 11 #include<stack> 12 #include<algorithm> 13 #include<map> 14 #include<math.h> 15 using namespace std; 16 typedef long long int64; 17 const int maxn = 105; 18 const int maxm = 1005; 19 const double pi = acos(-1.0); 20 21 int main(){ 22 int ca; 23 scanf("%d",&ca); 24 while( ca-- ){ 25 char s[ maxn ]; 26 scanf("%s",s); 27 int len = strlen( s ); 28 int a,b,c; 29 a = s[3]-'0'+10*(s[2]-'0')+100*( s[1]-'0' )+1000*( s[0]-'0' ); 30 b = 10*( s[5]-'0' )+s[6]-'0'; 31 c = 10*( s[8]-'0' )+s[9]-'0'; 32 if( b==2&&c==29){ 33 if( (a%4==0)&&(a%100!=0||a%400==0) ) 34 printf("-1\n"); 35 continue; 36 } 37 int sum = 0; 38 if( (a%4==0)&&(a%100!=0||a%400==0) ){ 39 if( b<3 ) 40 sum++; 41 } 42 for( int i=a+1;i<=18+a;i++ ){ 43 if( i==18+a ){ 44 if( (i%4==0)&&(i%100!=0||i%400==0) ){ 45 if( b>2 ) sum++; 46 } 47 } 48 else{ 49 if( (i%4==0)&&(i%100!=0||i%400==0) ){ 50 sum++; 51 } 52 } 53 } 54 printf("%d\n",sum+18*365); 55 } 56 return 0; 57 } 58 59 60
keep moving...