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> pll;
ll n,a,b;
map < pll , ll >vis;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> a >> b;
ll le,ri, ans = 0;
bool all = 0;
for(ll i = 0; i < n; i++){
cin >> le >> ri;
if(ri-le+1==a*b){
all = 1;
}
for(ll j = le; j <= ri&&!all; j++){
ll t = j;
ll x = (t+(t/b))%a;
ll y = t%b;
if(!vis[{x,y}]){
ans++;
}
vis[{x,y}]++;
}
}
if(all)ans=a*b;
cout << ans << endl;
}
# | 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... |