标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 23275 Accepted Submission(s): 7449
1 #include <stdio.h> 2 int num[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 3 int judge(int year) 4 { 5 if((year % 4 == 0 && year % 100!=0) || year % 400 ==0) 6 return 1 ; 7 else 8 return 0 ; 9 } 10 int main() 11 { 12 int i, j, n, y, m, d ; 13 14 scanf("%d", &n) ; 15 while(n--) 16 { 17 scanf("%d-%d-%d", &y, &m, &d) ; 18 if(m == 2 && judge(y) && d == 29 && !judge(y+18)) //没有18岁生日 ; 19 { 20 printf("-1\n") ; 21 continue ; 22 } 23 int sum = 0 ; 24 for(i = y; i < y+18; i++) 25 { 26 sum += 365 ; 27 if(judge(i)) 28 sum += 1 ; 29 } 30 int total = d ; 31 for(i = 1; i < m; i++) 32 total += num[i] ; 33 int gq = d, nw = d ; 34 if(judge(y) && m > 2) 35 gq += 1 ; 36 if(judge(y+18) && m > 2) 37 nw += 1 ; 38 int re = sum - gq + nw ; 39 printf("%d\n", re) ; 40 } 41 return 0 ; 42 }
能AC:
标签:
原文地址:http://www.cnblogs.com/fengshun/p/4674161.html