597A codeforces - Divisibility


597A codeforces - Divisibility






Solution in C++

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

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

lli k,a,b;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>k>>a>>b;
    b=(b>0)?(b/k)*k:(b%k)? ((b/k)-1)*k :b;
    a=(a<0)?(a/k)*k:(a%k)? ((a/k)+1)*k :a;
    cout<<((b<a)?0:max((b-a)/k,0LL)+1);
    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 التعليقات:

إرسال تعليق