#include<bits/stdc++.h>
using namespace std;
#define int long long
int n, A, B, D, M;
int get(int n) {
return min(n, D);
}
int lcm(int a, int b) {
return (a / __gcd(a, b)) * b;
}
signed main() {
#ifdef HOME
freopen("input.txt", "r", stdin);
#else
ios_base::sync_with_stdio(0); cin.tie(0);
#endif
cin >> n >> A >> B;
D = A / __gcd(A, B + 1);
int M = B * D;
set <int> ms;
while (n--) {
int l, r;
cin >> l >> r;
for (int i = l; i <= r; ++i) {
ms.insert(i % M);
}
}
cout << ms.size() << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
49 ms |
9848 KB |
Output is correct |
3 |
Correct |
82 ms |
13852 KB |
Output is correct |
4 |
Correct |
4 ms |
760 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
8 ms |
1016 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
424 KB |
Output is correct |
15 |
Correct |
39 ms |
5488 KB |
Output is correct |
16 |
Correct |
28 ms |
5468 KB |
Output is correct |
17 |
Correct |
79 ms |
8704 KB |
Output is correct |
18 |
Correct |
1 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Execution timed out |
5051 ms |
521624 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
276 KB |
Output is correct |
2 |
Correct |
119 ms |
24404 KB |
Output is correct |
3 |
Correct |
114 ms |
24312 KB |
Output is correct |
4 |
Correct |
113 ms |
23160 KB |
Output is correct |
5 |
Execution timed out |
5057 ms |
47036 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
771 ms |
47560 KB |
Output is correct |
3 |
Runtime error |
3104 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
771 ms |
47560 KB |
Output is correct |
3 |
Runtime error |
3104 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
771 ms |
47560 KB |
Output is correct |
3 |
Runtime error |
3104 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Runtime error |
3001 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
49 ms |
9848 KB |
Output is correct |
3 |
Correct |
82 ms |
13852 KB |
Output is correct |
4 |
Correct |
4 ms |
760 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
8 ms |
1016 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
424 KB |
Output is correct |
15 |
Correct |
39 ms |
5488 KB |
Output is correct |
16 |
Correct |
28 ms |
5468 KB |
Output is correct |
17 |
Correct |
79 ms |
8704 KB |
Output is correct |
18 |
Correct |
1 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Execution timed out |
5051 ms |
521624 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |