UVA 10070 Leap Year or Not Leap Year and …





Hints: In This Problem You have to use Big Integer Remainder. Here is Tutorial

#include <bits/stdc++.h>
using namespace std;

int rem(string year,int n)
{
    int i,j,y=0;
    for(i=0;i<year.length();i++)
    {
        y=(y*10+(year[i]-'0'))%n;   //Big Integer Modulo Arithmatic
    }
    return y;
}

int main()
{
    int y,l,h,b,k=0;
    string year;
    //freopen("lin.txt","r",stdin);
    //freopen("lout.txt","w",stdout);

    while(cin>>year)
    {
        l=0;
        h=0;
        b=0;
        if(k>0)
        {
           cout<<endl;
        }
        k++;

        if((((rem(year,4)==0)&&(rem(year,100)!=0))||(rem(year,400)==0)))
        {
            cout<<"This is leap year."<<endl;
            l=1;

        }
        if(rem(year,15)==0)
        {
            cout<<"This is huluculu festival year."<<endl;
            h=1;

        }
        if(rem(year,55)==0 && l==1)
        {
            cout<<"This is bulukulu festival year."<<endl;
            b=1;
        }

        if(l==0 && h==0 && b==0)
        {
            cout<<"This is an ordinary year."<<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