Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <list>
- #include <map>
- #include <set>
- #include <queue>
- #include <deque>
- #include <stack>
- #include <bitset>
- #include <algorithm>
- #include <functional>
- #include <numeric>
- #include <utility>
- #include <sstream>
- #include <iostream>
- #include <iomanip>
- #include <cstdio>
- #include <cmath>
- #include <cstdlib>
- #include <ctime>
- #include <limits>
- #include <cstring>
- #include <string>
- using namespace std;
- int pel(string s){string t;t=s;reverse(t.begin(),t.end());if(s==t)return 1;return 0;}
- string toString(int n){ostringstream ost;ost<<n;ost.flush();return ost.str();}
- int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;}
- bool isprime(int m){if(m<2) return 0;for( int i=2; i*i<=m ; i++)if(m%i==0)return 0; return 1;return 0;}
- # define eps 1e-8
- # define inf (1<<30)
- # define pi (2*acos(0.0))
- # define __(array,w) memset(array,w,sizeof array)
- # define FOR(i, a, b) for (int i=a; i<b; i++)
- # define REP(i, a) FOR(i,0,a)
- # define all(c) (c).begin(), (c).end()
- # define sz(x) x.size()
- # define pb push_back
- # define UNQ(s) {sort(all(s));(s).erase(unique(all(s)),s.end());}
- # define rive(s) reverse(s.begin(),s.end())
- # define out(a) cout<<#a<<" #"<<a<<endl;
- # define caout(a) cout<<#a<<" "<<++a<<": ";
- # define X first
- # define Y second
- # define MP make_pair
- typedef long long LL;
- //typedef __int64 LL;
- typedef vector<int>vi;
- typedef vector<string>vs;
- typedef pair<int,int>pri;
- typedef map<string,int>msi;
- typedef map<vector<int>,int>mvi;
- inline bool iseq(double x,double y){if(fabs(x-y)<eps)return true;return false;}
- template<typename T>inline double hpt(T x1,T y1,T x2,T y2){return hypot(x1-x2,y1-y2);}
- template<typename T>inline T gcd(T a,T b){if(!b)return a;else return gcd(b,a%b);}
- template<typename T>inline void extended_euclid(T a,T b,T &x,T &y){if(a%b==0)x=0,y=1;else{extended_euclid(b,a%b,x,y);T temp=x;x=y;y=-y*(a/b)+temp;}}
- template<typename T>inline T bigmod(T b,T p,T m){if(!p)return 1;else if(!(p%2)){T x=bigmod(b,p/2,m);return x*x;}else return ((b%m)*bigmod(b,p-1,m))%m;}
- #define PS 5
- int prime[PS/32+1];
- void setbit(int i){int p=i>>5,q=i&31;prime[p]|=(1<<q);}
- bool checkbit(int i){int p=i>>5,q=i&31;return prime[p]&(1<<q)?true:false;}
- void buildprime(int n){int i,j,k=sqrt(double(n));prime[0]=3;for(i=4;i<n;i+=2)setbit(i);for(i=3;i<=k;i+=2){if(!checkbit(i)){int ii=i+i;for(j=i*i;j<n;j+=ii)setbit(j);}}}
- bool leap(long long n)
- {
- if(n%4==0)
- {
- if(n%100==0)
- {
- if(n%400==0)return 1;
- }
- return 1;
- }
- return 0;
- }
- int main()
- {
- #ifndef ONLINE_JUDGE
- //freopen("in.txt","r",stdin);
- //freopen("out.txt","w",stdout);
- #endif
- int test,Case=0;
- map<string,int>mp;
- mp["January"]=1; mp["February"]=2; mp["March"]=3; mp["April"]=4; mp["May"]=5; mp["June"]=6; mp["July"]=7;
- mp["August"]=8; mp["September"]=9; mp["October"]=10; mp["November"]=11; mp["December"]=12;
- cin>>test;
- while(test--){
- bool f1=0,f2=0;
- string mon1,mon2;
- long long date1,date2,year1,year2;
- cin>>mon1;
- scanf("%lld,%lld",&date1,&year1);
- cin>>mon2;
- scanf("%lld,%lld",&date2,&year2);
- long long res;
- long long a,b;
- res= ((year2/4)-((year1-1) /4));
- a=((year2/100)-((year1-1)/100));
- b=((year2/400)-((year1-1)/400));
- res=res-a+b;
- if(leap(year1)&& mp[mon1]>2)res--;
- if(leap(year2))
- {
- if(mp[mon2]<2 || (mp[mon2]==2&&date2<29))res--;
- }
- printf("Case %d: ",++Case);
- cout<<res<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement