//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC optimize("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#pragma pack(1)
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define int long long
#define pii pair<int,int>
#define x first
#define y second
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set;
int findt(int a,int b){
int go=b+1,g=__gcd(go,a);
// cout<<go<<" "<<a<<' '<<b<<" "<<g<<'\n';
// lcm(go,a)/go*b
if ((double)(log10(a/g)+log10(b))>=18.0001) return 2e18;
else return a/g*b;
}
int vis[1500000];
signed main(){
fast
int n,a,b; cin>>n>>a>>b;
int t=findt(a,b);
for (int i=1;i<=n;i++){
int l,r; cin>>l>>r;
l%=t; r%=t;
if (l<=r){
vis[l]++; vis[r+1]--;
}
else {
vis[0]++; vis[r+1]--;
vis[l]++; vis[t]--;
}
}
int ans=0;
for (int i=0;i<1500000;i++){
if (i) vis[i]+=vis[i-1];
ans+=(vis[i]>0);
}
cout<<ans<<'\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
11976 KB |
Output is correct |
2 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
11980 KB |
Output is correct |
2 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
12000 KB |
Output is correct |
2 |
Correct |
11 ms |
12024 KB |
Output is correct |
3 |
Correct |
11 ms |
11964 KB |
Output is correct |
4 |
Correct |
11 ms |
12036 KB |
Output is correct |
5 |
Correct |
256 ms |
11972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
11988 KB |
Output is correct |
2 |
Correct |
341 ms |
11988 KB |
Output is correct |
3 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
11988 KB |
Output is correct |
2 |
Correct |
341 ms |
11988 KB |
Output is correct |
3 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
11988 KB |
Output is correct |
2 |
Correct |
341 ms |
11988 KB |
Output is correct |
3 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
12052 KB |
Output is correct |
2 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
11976 KB |
Output is correct |
2 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |