题目:http://codeforces.com/contest/597/problem/A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include<iostream> using namespace std; inline long long cal(long long a,long long b,long long k){ return b/k-(a-1)/k; } int main(){ long long k,a,b; cin>>k>>a>>b; if(a>0)cout<<cal(a,b,k); else if(b<0)cout<<cal(-b,-a,k); else if(a==0)cout<<b/k+1; else if(b==0)cout<<(-a)/k+1; else if(a<0&&b>0)cout<<cal(1,b,k)+cal(1,-a,k)+1; } |