#include <iostream>
#include <set>
using namespace std;
set <pair<long long,long long> > s;
long long n,i,j,l,r,A,B;
long long gcd(long long x,long long y)
{
if((!x)||(!y)) return (x+y);
return gcd(y,x%y);
}
int main()
{
cin>>n>>A>>B;
long long t=gcd(A,B+1);
for(i=1;i<=n;i++)
{
cin>>l>>r;
for(j=l;j<=r;j++)
s.insert({(j/B)%(A/t),j%B});
}
cout<<s.size();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
84 ms |
12448 KB |
Output is correct |
3 |
Correct |
123 ms |
18088 KB |
Output is correct |
4 |
Correct |
4 ms |
888 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
508 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
11 ms |
1144 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
252 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
54 ms |
7032 KB |
Output is correct |
16 |
Correct |
57 ms |
6904 KB |
Output is correct |
17 |
Correct |
288 ms |
6776 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Runtime error |
4994 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 |
256 KB |
Output is correct |
2 |
Correct |
168 ms |
32336 KB |
Output is correct |
3 |
Correct |
158 ms |
32120 KB |
Output is correct |
4 |
Correct |
155 ms |
30584 KB |
Output is correct |
5 |
Execution timed out |
5050 ms |
62584 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2909 ms |
63300 KB |
Output is correct |
3 |
Runtime error |
3022 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 |
256 KB |
Output is correct |
2 |
Correct |
2909 ms |
63300 KB |
Output is correct |
3 |
Runtime error |
3022 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 |
256 KB |
Output is correct |
2 |
Correct |
2909 ms |
63300 KB |
Output is correct |
3 |
Runtime error |
3022 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 |
256 KB |
Output is correct |
2 |
Runtime error |
2846 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 |
256 KB |
Output is correct |
2 |
Correct |
84 ms |
12448 KB |
Output is correct |
3 |
Correct |
123 ms |
18088 KB |
Output is correct |
4 |
Correct |
4 ms |
888 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
508 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
11 ms |
1144 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
252 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
54 ms |
7032 KB |
Output is correct |
16 |
Correct |
57 ms |
6904 KB |
Output is correct |
17 |
Correct |
288 ms |
6776 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Runtime error |
4994 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
21 |
Halted |
0 ms |
0 KB |
- |