1 条题解
-
0
#include<bits/stdc++.h> #define int long long using namespace std; const int inf=1e18; string s1,s2; int a,b,c,a1,b1,c1,t1,t2; int ans,m[20]={0,31,28,31,30,31,30,31,31,30,31,30,31}; bool ly(int y){ if(y%400==0||(y%4==0&&y%100!=0)) return 1; return 0; } signed main(){ ios::sync_with_stdio(0); cin.tie(0),cout.tie(0); cin>>s1>>s2; if(s1>s2) swap(s1,s2); a=stoll(s1.substr(0,4)); b=stoll(s1.substr(5,2)); c=stoll(s1.substr(8,2)); a1=stoll(s2.substr(0,4)); b1=stoll(s2.substr(5,2)); c1=stoll(s2.substr(8,2)); for(int i=a;i<=a1;i++){ if(ly(i)) ans+=366; else ans+=365; } for(int i=1;i<b;i++){ t1+=m[i]; if(ly(a)&&i==2) t1++; } t1+=c; t2+=m[b1]-c1; if(ly(a1)&&b1==2) t2++; for(int i=b1+1;i<=12;i++){ t2+=m[i]; if(ly(a1)&&i==2) t2++; } ans=ans-t1-t2; cout<<ans; return 0; }
信息
- ID
- 4595
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 1
- 标签
- 递交数
- 70
- 已通过
- 37
- 上传者