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 fast ios_base::sync_with_stdio();cin.tie();cout.tie();
#define en cout<<endl;
#define ops cout<<"ops"<<endl;
#define line cout<<"---------------------------"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pllll;
typedef string str;
const ll DIM = 6e4 + 7;
const ll DIMM = 1e2 + 7;
const ll DDIM = 7;
const ll INF = 1e18 + 7;
const ll X = 1e5 + 7;
const ll BS = 2e5 + 7;
const ll AS = 26 + 7;
const ll MODULO = 1e9 + 7;
ll nt,n,m,k,q;
ll val,val1;
ll A,B;
ll l,r;
ll x,y,t;
ll res;
set<pllll> s;
int main()
{
fast;
//ll x1,y1,x2,y2;
cin>>n>>A>>B;
if(n==1){
cin>>l>>r;
res=(r-l+1)/B;
if(res>=A){
res=A;
res*=B;
}
else res=r-l+1;
cout<<res<<endl;
return 0;
}
for(int i=1;i<=n;i++){
cin>>l>>r;
for(ll i=l;i<=r;i++){
y=i%B;
x=(i+i/B)%A;
s.insert({x,y});
}
}
cout<<s.size()<<endl;
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... |