import sys
input = lambda: sys.stdin.readline().strip()
from math import *
n,a,b = map(int, input().split())
ranges = []
for i in range(n):
ranges.append(list(map(int, input().split())))
k = (lcm(a,b+1)//(b+1)) * b
print(k)
new = []
ans = 0
flag = False
for i in ranges:
if i[1]-i[0]+1 >= k:
flag = True
if i[0]%k > i[1]%k:
new.append([i[0]%k,k-1])
new.append([0,i[1]%k])
else:
new.append([i[0]%k, i[1]%k])
new.sort()
realnew = []
if flag:
print(k)
else:
cur = k
for i in range(len(new)):
if not realnew:
realnew.append(new[i])
continue
if realnew[-1][1] >= new[i][0]:
realnew[-1][1] = max(realnew[-1][1],new[i][1])
else:
realnew.append(new[i])
for i in realnew:
ans += i[1]-i[0]+1
print(ans)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
66 ms |
20172 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
67 ms |
20104 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
60 ms |
20124 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
66 ms |
20188 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
66 ms |
20188 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
66 ms |
20188 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
70 ms |
20212 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
66 ms |
20172 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |