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 <iostream>
#include <set>
using namespace std;
set <long long > s;
long long n,i,j,l,r,A,B,per;
long long lim=1LL*1e18+1;
long long gcd(long long x,long long y)
{
if((!x)||(!y)) return (x+y);
return gcd(y,x%y);
}
int main()
{
cin>>n>>A>>B;
long long t=gcd(A,B+1);
A/=t;
long long per;
if(lim/A<=B) per=lim;
else per=1LL*A*B;
for(i=1;i<=n;i++)
{
cin>>l>>r;
for(j=l;j<=r;j++)
s.insert(j%per);
}
cout<<s.size();
return 0;
}
# | 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... |