#include<bits/stdc++.h>
using namespace std;
#define int long long
int gcd(int x, int y)
{
while(x>0)
{
int r = y%x;
y=x;
x=r;
}
return y;
}
map<pair<int,int>,int> mp;
signed main()
{
int n,A,B,cnt=0,B1;
cin>>n>>A>>B;
int gc = gcd(A,B+1);
A /= gc;
B1 = (B+1)/gc;
int le,ri;
for(int i=1;i<=n;i++)
{
cin>>le>>ri;
for(int t=le;t<=ri;t++)
{
int p = t/B;
pair<int,int> aux = {(B1*p)%A, t%B};
if(mp[aux]==0)
{
mp[aux]++;
cnt++;
}
}
}
cout<<cnt;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
48 ms |
12412 KB |
Output is correct |
3 |
Correct |
86 ms |
17836 KB |
Output is correct |
4 |
Correct |
2 ms |
856 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
5 ms |
1112 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
29 ms |
7132 KB |
Output is correct |
16 |
Correct |
28 ms |
7004 KB |
Output is correct |
17 |
Correct |
118 ms |
10320 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
3402 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
130 ms |
32280 KB |
Output is correct |
3 |
Correct |
118 ms |
32112 KB |
Output is correct |
4 |
Correct |
117 ms |
30476 KB |
Output is correct |
5 |
Execution timed out |
5064 ms |
62560 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1180 ms |
62968 KB |
Output is correct |
3 |
Runtime error |
2066 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1180 ms |
62968 KB |
Output is correct |
3 |
Runtime error |
2066 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1180 ms |
62968 KB |
Output is correct |
3 |
Runtime error |
2066 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Runtime error |
2434 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
48 ms |
12412 KB |
Output is correct |
3 |
Correct |
86 ms |
17836 KB |
Output is correct |
4 |
Correct |
2 ms |
856 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
5 ms |
1112 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
29 ms |
7132 KB |
Output is correct |
16 |
Correct |
28 ms |
7004 KB |
Output is correct |
17 |
Correct |
118 ms |
10320 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Runtime error |
3402 ms |
524288 KB |
Execution killed with signal 9 |
21 |
Halted |
0 ms |
0 KB |
- |