UVA 13275 Leap Birthdays









#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,k,l,m,n,c,d,y1,y2;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        c=0;
        cin>>d>>m>>y1>>y2;
        if(m!=2)
        {
            printf("Case %lld: %lld\n",i,(y2-y1));
        }
        else
        {
            if(d!=29)
            {
                printf("Case %lld: %lld\n",i,(y2-y1));
            }
            else
            {

                for(j=y1;j<=y2;j=j+4)
                {
                    if((j%4==0 && j%100!=0) || j%400==0 )
                    {
                        c++;
                    }

                }
                printf("Case %lld: %lld\n",i,c-1);
            }
        }
    }

    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