#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;
B = B1-1;
int le,ri;
for(int i=1;i<=n;i++)
{
cin>>le>>ri;
for(int t=le;t<=ri;t++)
{
pair<int,int> aux = {(t+t/B)%A, t%B};
if(mp[aux]==0)
{
mp[aux]++;
cnt++;
}
}
}
cout<<cnt;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
62 ms |
12644 KB |
Output is correct |
3 |
Correct |
67 ms |
18260 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
3495 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 |
142 ms |
32384 KB |
Output is correct |
3 |
Correct |
183 ms |
32180 KB |
Output is correct |
4 |
Correct |
123 ms |
30548 KB |
Output is correct |
5 |
Execution timed out |
5077 ms |
62548 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1070 ms |
100028 KB |
Output is correct |
3 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 8 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1070 ms |
100028 KB |
Output is correct |
3 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 8 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1070 ms |
100028 KB |
Output is correct |
3 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 8 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
1573 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
62 ms |
12644 KB |
Output is correct |
3 |
Correct |
67 ms |
18260 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |