Lightoj 1414 February 29 Solution



Problem Link:  https://lightoj.com/problem/february-29 

Solution in C++:

///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat  Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
///**********ALLAH IS ALMIGHTY************///
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll d1,d2,y1,y2,sy,ey,t,i=0;
    cin>>t;
    while(t--)
    {

        string m1,m2;
        char c;
        cin>>m1>>d1>>c>>y1;
        cin>>m2>>d2>>c>>y2;
        if((m1=="January")||((m1=="February")&&(d1<=29)))   y1--;
        sy=(y1/4)-(y1/100)+(y1/400);
        if((m2=="January")||((m2=="February")&&(d2<=28)))   y2--;
        ey=(y2/4)-(y2/100)+(y2/400);
        printf("Case %lld: ",++i);
        cout<<abs(sy-ey)<<endl;

    }
}

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.