题目:http://codeforces.com/contest/304/problem/B
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <fstream>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <sstream>
using namespace std ;
int month[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int leapyear(int y){
return (!(y%4) && y%100) || (!(y%400));
}
int main(){
int ys,ms,ds,ye,me,de;
while(~scanf("%d:%d:%d",&ys,&ms,&ds)){
scanf("%d:%d:%d",&ye,&me,&de);
if(ye<ys || (ye == ys && ms>me) || (ye == ys && ms == me && ds > de)){
swap(ys, ye);
swap(ms, me);
swap(ds, de);
}
int ans = 0;
if(ys == ye && ms == me){
printf("%d\n",de-ds);
continue;
}
if(ys == ye){
if(leapyear(ys) && ms == 2)
ans += month[2]+1 - ds;
else
ans += month[ms] - ds;
for(int i = ms+1;i < me;i++){
if(leapyear(ys) && i == 2)
ans += month[i]+1;
else
ans += month[i];
}
ans += de;
printf("%d\n",ans);
continue;
}
if(leapyear(ys) && ms == 2)
ans += month[2]+1 - ds;
else
ans += month[ms] - ds;
//printf("%d\n",ans);
for(int i = ms+1;i <= 12;i++){
if(leapyear(ys) && i == 2)
ans += month[i]+1;
else
ans += month[i];
}
//printf("%d\n",ans);
for(int i = ys+1;i < ye;i++){
if(leapyear(i))
ans += 366;
else
ans += 365;
}
//printf("%d\n",ans);
for(int i = 1;i < me;i++){
if(leapyear(ye) && i == 2)
ans += month[i]+1;
else
ans += month[i];
}
//printf("%d\n",ans);
ans += de;
printf("%d\n",ans);
}
return 0;
}