#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fi first
#define se second
#define pb push_back
#define TC int t; cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
//*AC BERSAMA ALLAH FORTIS FORTUNA ADIUVAT
//# nyampah
ll gcd(ll a, ll b){
if(b==0) return a;
return gcd(b,a%b);
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n,a,b;
cin>>n>>a>>b;
vector<bool> freq(1000005);
set<pair<ll,ll> > sp;
vector<bool> dif(1000005,1);
for(int i=1;i<=a*b;i++){
int idx=i;
if(i==a*b) idx=0;
if(sp.count(make_pair((i+i/b)%a,i%b))){
dif[idx]=0;
}
else sp.insert(make_pair((i+i/b)%a,i%b));
}
for(int i=1;i<=n;i++){
int l,r; cin>>l>>r;
if(r-l>a*b) r=l+a*b;
for(int j=l;j<=r;j++){
freq[j%(a*b)]=1;
}
}
int cnt=0;
for(int i=0;i<1000000;i++){
if(freq[i] && dif[i]) {
cnt++;
}
}
cout<<cnt<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Incorrect |
2685 ms |
405348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Runtime error |
3692 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Incorrect |
263 ms |
60776 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
448 KB |
Output is correct |
2 |
Incorrect |
373 ms |
77760 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
448 KB |
Output is correct |
2 |
Incorrect |
373 ms |
77760 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
448 KB |
Output is correct |
2 |
Incorrect |
373 ms |
77760 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Runtime error |
1973 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Incorrect |
2685 ms |
405348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |