#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define ios ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
using namespace std;
int main() {
ios
int n;
cin >> n;
ll A, B;
cin >> A >> B;
ll S = 0;
ll val = A * B / __gcd(B - 1, A);
map <ll, ll> was;
ll l[n], r[n], ans = 0;
for (int i = 0; i < n; ++ i) {
cin >> l[i] >> r[i];
S += r[i] - l[i] + 1;
}
if (A > 1e18 / B + 1) {
cout << S;
return 0;
}
for (int i = 0; i < n; ++ i) {
for (int j = l[i]; j <= r[i]; ++ j) {
if (was[j % val]);
else ++ ans;
was[j % val] = 1;
}
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Execution timed out |
5087 ms |
405532 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Execution timed out |
5078 ms |
507500 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Execution timed out |
5068 ms |
60532 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Execution timed out |
5038 ms |
35112 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Execution timed out |
5038 ms |
35112 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Execution timed out |
5038 ms |
35112 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Runtime error |
4869 ms |
524292 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Execution timed out |
5087 ms |
405532 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |