标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 23314 Accepted Submission(s): 7461
#include<stdio.h> #include<string.h> int run(int x) { if(x%4==0&&x%100!=0||x%400==0) return 1; return 0; } int main() { int n,j,i,s,t,l,sum; int y,m,d; int s1[14]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int s2[14]={0,31,29,31,30,31,30,31,31,30,31,30,31}; scanf("%d",&n); while(n--) { scanf("%d-%d-%d",&y,&m,&d); if(!run(y+18)) { if(m==2&&d==29) { printf("-1\n"); continue; } } s=0; for(i=y;i<y+18;i++) { if(run(i)) s+=366; else s+=365; } if(run(y+18)) { //s+=366; for(i=1;i<m;i++) { s+=s2[i]; } s+=d; } else { //s+=365; for(i=1;i<m;i++) { s+=s1[i]; } s+=d; } sum=0; if(run(y)) { for(i=1;i<m;i++) { sum+=s2[i]; } sum+=d; } else { for(i=1;i<m;i++) { sum+=s1[i]; } sum+=d; } printf("%d\n",s-sum); } return 0; }
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4674401.html