标签:
//zzuli 1878
#include<iostream> #include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> #include<ctype.h> #include<algorithm> using namespace std; #define N 1010000 #define INF 0x3f3f3f3f int yearday[N]; int IsLeap(int year) { return ((year%4==0&&year%100!=0) || year%400==0); } int main() { int T, y1, m1, d1, y2, m2, d2, sum; int tab[2][13]={{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; int leap; yearday[1899]=0; for(int i=1900; i<=1000000; i++) yearday[i]=yearday[i-1]+(IsLeap(i)==1 ? 366 : 365); scanf("%d", &T); while(T--) { scanf("%d%d%d%d%d%d", &y1, &m1, &d1, &y2, &m2, &d2); sum=0; if(y1==y2) { leap=IsLeap(y1); for(int i=m1+1; i<m2; i++) sum+=tab[leap][i]; if(m1<m2) { sum+=tab[leap][m1]-d1; sum+=d2; } else sum+=d2-d1; printf("%d\n", sum); } else { leap=IsLeap(y1); for(int i=m1+1; i<=12; i++) sum+=tab[leap][i]; sum+=tab[leap][m1]-d1; leap=IsLeap(y2); for(int i=1; i<m2; i++) sum+=tab[leap][i]; sum+=d2; sum+=yearday[y2-1]-yearday[y1]; printf("%d\n", sum); } } return 0; }
标签:
原文地址:http://www.cnblogs.com/9968jie/p/5405556.html