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 ll;
typedef pair <ll,ll> p;
const int N = 1e6+56;
const ll inf = 4e18;
ll n,a,b,l[N],r[N];
void prvi(){
map <p,bool> mapa;
for(int i = 1; i <= n; i++){
for(int t = l[i]; t <= r[i]; t++){
ll x = (t+t/b)%a,y = t%b;
mapa[p(x,y)] = 1;
}
}
cout << mapa.size() << endl;
}
void drugi(){
ll period = a*b;
ll x = l[1],y = r[1];
if(x-y+1 >= period){
cout << period << endl;
}
else{
cout << (x-y+1)%period << endl;
}
}
void treci(){
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> a >> b;
ll s = 0;
for(int i = 1; i <= n; i++){
cin >> l[i] >> r[i];
s += r[i]-l[i]+1;
}
/*for(int t = 0; t <= 300; t++){
ll x = (t+t/b)%a,y = t%b;
cout << "za t = " << t << " " << x << " " << y << endl;
}*/
if(s <= 1000000){
prvi();
return 0;
}
if(n == 1){
drugi();
return 0;
}
if(a <= b/inf && a*b <= 1000000){
treci();
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... |