Uva 13275 - Leap Birthdays solution


Solve in C++:

#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,p,m,n,count=0,d,y1,y2;
    scanf("%lld",&n);
    for(i=1; i<=n; i++)
    {
        count=0;
        scanf("%lld%lld%lld%lld",&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(p=y1; p<=y2; p=p+4)
                {
                    if((p%4==0 && p%100!=0) || p%400==0 )
                    {
                        count++;
                    }

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

    return 0;

No comments

Most View Post

Recent post

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.