456B Codeforces - Fedya and Maths


456B Codeforces - Fedya and maths






Solution in C++

#include <bits/stdc++.h>

using namespace std;

#define pii pair<int,int>
typedef long long int lli;

int n,m=1;
string inp;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>inp;
    if(inp.size()==1)n=inp[0]-'0';
    else n=(inp[inp.size()-2]-'0')*10+inp[inp.size()-1]-'0';
    m+=((n%2)?4:6);
    if(n%4==1)m+=5;
    else if(n%4==2)m+=13;
    else if(n%4==3)m+=15;
    else m+=1+6;
    cout<<m%5;
    return 0;
}

Share on Google Plus

About Mohamed Sobhi

My name is Mo.Sobhy ,I study at School excelling high school in Ain Shams ,Cairo
My hobbies is programming ,and web development ,playing chess and writing horror stories.
    Blogger Comment
    Facebook Comment

0 التعليقات:

إرسال تعليق