#include <iostream>
#include <set>
//#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
ll N,A,B;
ll L[1000006],R[1000006];
ll x,y;
set<pll> S;
ll G;
ll ans;
ll P[1000006];
bool is_in(ll x){
return P[x];
}
int main(){
cin>>N>>A>>B;
G=A/__gcd(A,B+1);
ll M=(A*B);
for(int i=0;i<N;i++){
cin>>L[i]>>R[i];
x=L[i]%M;
y=R[i]%M;
if(y<x){
if(R[i]-L[i]>=M)
S.insert({0,M-1});
else{
S.insert({0,y});
S.insert({x,M-1});
}
}
else
S.insert({x,y});
}
for(pll p:S){
P[p.first]++;
P[p.second+1]--;
}
for(int i=1;i<M;i++)
P[i]+=P[i-1];
for(ll y=0;y<B;y++)
for(ll k=0;k<G;k++)
if(is_in(B*k+y))
ans++;
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Runtime error |
36 ms |
4136 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Runtime error |
4 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
17 ms |
7932 KB |
Output is correct |
3 |
Correct |
15 ms |
8160 KB |
Output is correct |
4 |
Correct |
14 ms |
6776 KB |
Output is correct |
5 |
Correct |
1861 ms |
26168 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
372 KB |
Output is correct |
2 |
Runtime error |
3045 ms |
176760 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
372 KB |
Output is correct |
2 |
Runtime error |
3045 ms |
176760 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
372 KB |
Output is correct |
2 |
Runtime error |
3045 ms |
176760 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Runtime error |
304 ms |
18040 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Runtime error |
36 ms |
4136 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |