#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
void solve(){
set<pair<ll, ll>> s;
ll n, A, B; cin>>n>>A>>B;
if(n>1){
for(int i=0; i<n; i++){
ll x, y; cin>>x>>y;
for(ll t = x; t<=y; t++){
ll p = (t+(t/B))%A;
ll q = t%B;
s.insert({p,q});
}
}
cout<<s.size()<<"\n";
}
else{
ll n, A, B; cin>>n>>A>>B;
ll x, y; cin>>x>>y;
ll X = A/(gcd(B+1, A));
ll t;
int powX=0, powB=0;
ll xxx = X;
while(xxx>0){
xxx/=2;
powX+=1;
}
xxx=B;
while(xxx>0){
xxx/=2;
powB+=1;
}
if(powB+powX>61) t=2e18;
else t = B*X;
cout<<min<ll>(y-x+1, t)<<"\n";
}
return;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t=1; //cin>>t;
while(t--){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |