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;
#define int long long
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,A,B;
cin >> n >> A >> B;
int modulus;
bool edgecase = false;
if((B+1)%A==0){
modulus = B;
} else {
modulus = A*B;
if(INT64_MAX/A<B or INT64_MAX/B<A)edgecase=true;
}
int totalsum = 0;
set<int> answers;
for(int i=1;i<=n;i++){
int l,r;cin>>l>>r;
for(int x=l;x<=r;x++){
totalsum++;
answers.insert(x%modulus);
}
}
if(edgecase)cout << totalsum << '\n';
else cout << answers.size() << '\n';
}
# | 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... |