LightOj 1414 February 29






#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int d1,d2,y1,y2,i,j,k,l,n,t,x,y,z,u,w;
    string m1,m2;;
    char c;
    //freopen("1414in.txt","r",stdin);
    //freopen("1414out.txt","w",stdout);
    cin>>t;
    for(i=1;i<=t;i++)
    {
        cin>>m1>>d1>>c>>y1;
        cin>>m2>>d2>>c>>y2;
        l=0;

        if(m1=="January" || m1=="February")
        {
            y1=y1; //include that year
        }
        else
        {
            y1++; //exclude that year
        }
        if(m2=="January" || (m2=="February" && d2<29))
        {
            y2--; //exclude that year
        }

            y=(y2/4)-((y1-1)/4);
            z=(y2/100)-((y1-1)/100);
            w=(y2/400)-((y1-1)/400);
            l=(y-z+w);



        cout<<"Case "<<i<<": "<<l<<endl;

    }
  return 0;
}

Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment