#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,A,B;
cin >> n >> A >> B;
__int128 modulus;
if((B+1)%A==0){
modulus = B;
} else if(A%(B+1)==0){
modulus = __int128(A/(B+1))*__int128(B);
} else {
modulus = __int128(A)*__int128(B);
}
set<__int128> answers;
for(int i=1;i<=n;i++){
int l,r;cin>>l>>r;
for(int x=l;x<=r;x++){
answers.insert(__int128(x)%modulus);
}
}
cout << answers.size() << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
34 ms |
12624 KB |
Output is correct |
3 |
Correct |
54 ms |
18436 KB |
Output is correct |
4 |
Incorrect |
2 ms |
1112 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
2016 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
94 ms |
32280 KB |
Output is correct |
3 |
Correct |
97 ms |
32420 KB |
Output is correct |
4 |
Correct |
90 ms |
30664 KB |
Output is correct |
5 |
Execution timed out |
5040 ms |
62488 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
704 KB |
Output is correct |
2 |
Correct |
472 ms |
100336 KB |
Output is correct |
3 |
Runtime error |
1541 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
704 KB |
Output is correct |
2 |
Correct |
472 ms |
100336 KB |
Output is correct |
3 |
Runtime error |
1541 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
704 KB |
Output is correct |
2 |
Correct |
472 ms |
100336 KB |
Output is correct |
3 |
Runtime error |
1541 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
1489 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
34 ms |
12624 KB |
Output is correct |
3 |
Correct |
54 ms |
18436 KB |
Output is correct |
4 |
Incorrect |
2 ms |
1112 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |