#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;
int modulus;
bool edgecase = false;
if((B+1)%A==0){
modulus = B;
} else {
modulus = A*B;
if(INT64_MAX/A<B or INT64_MAX/B<A)edgecase=true;
}
int totalsum = 0;
set<int> answers;
for(int i=1;i<=n;i++){
int l,r;cin>>l>>r;
for(int x=l;x<=r;x++){
totalsum++;
answers.insert(x%modulus);
}
}
if(edgecase)cout << totalsum << '\n';
else cout << answers.size() << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
30 ms |
9808 KB |
Output is correct |
3 |
Correct |
42 ms |
14020 KB |
Output is correct |
4 |
Incorrect |
2 ms |
860 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
2472 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
78 ms |
24456 KB |
Output is correct |
3 |
Correct |
72 ms |
24144 KB |
Output is correct |
4 |
Correct |
79 ms |
23120 KB |
Output is correct |
5 |
Execution timed out |
5012 ms |
46932 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
418 ms |
84388 KB |
Output is correct |
3 |
Runtime error |
1694 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
418 ms |
84388 KB |
Output is correct |
3 |
Runtime error |
1694 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
418 ms |
84388 KB |
Output is correct |
3 |
Runtime error |
1694 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
1698 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
30 ms |
9808 KB |
Output is correct |
3 |
Correct |
42 ms |
14020 KB |
Output is correct |
4 |
Incorrect |
2 ms |
860 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |