869B Codeforces - The eternal immortality



869B Codeforces - The eternal immortality






Solution in C++


#include <bits/stdc++.h>

using namespace std;

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

lli n,m,sol=1;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>m;
    if(n>m)swap(n,m);
    if( ((n%10)+1<=2 && n%10>=1 && m%10>=5) || (abs(n-m)>10) )return cout<<0,0;
    else{
        for(lli i=n+1;i<=m;i++)
            sol=(sol*(i%10))%10;
    }
    cout<<sol;
    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 التعليقات:

إرسال تعليق