This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)
lld GCD(lld x, lld y){
if(y==0)return x;
return GCD(y,x%y);
}
int main(){
lld n,A,B;
cin>>n>>A>>B;
lld l[n];
lld r[n];
rep(i,0,n)cin>>l[i]>>r[i];
lld D=GCD(A,B+1);
set<pair<lld,lld> >s;
rep(i,0,n){
for(lld j=l[i];j<=r[i];j++){
s.insert(pair<lld,lld>((j+(j/B))%A,j%B));
}
}
cout<<s.size()<<endl;
//trav(a,s)cout<<a.first<<" "<<a.second<<endl;
return 0;
}
Compilation message (stderr)
strange_device.cpp: In function 'int main()':
strange_device.cpp:18:7: warning: unused variable 'D' [-Wunused-variable]
lld D=GCD(A,B+1);
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |