#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<__int128,int> mp;
signed main()
{
int n,A,B,cnt=0;
cin>>n>>A>>B;
A = A / gcd(A,B+1);
int le,ri;
__int128 copA=A,copB=B;
__int128 prod=copA*copB;
for(int i=1;i<=n;i++)
{
cin>>le>>ri;
for(__int128 t=le;t<=ri;t++)
{
/*int p = t/B;
pair<int,int> aux = {p%A, t%B};
if(mp[aux]==0)
{
mp[aux]++;
cnt++;
}*/
if(mp[t%prod]==0)
{
mp[t%prod]=1;
cnt++;
}
}
}
cout<<cnt;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
42 ms |
15648 KB |
Output is correct |
3 |
Correct |
68 ms |
22808 KB |
Output is correct |
4 |
Correct |
2 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
5 ms |
1556 KB |
Output is correct |
10 |
Correct |
0 ms |
388 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 |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
26 ms |
8808 KB |
Output is correct |
16 |
Correct |
29 ms |
8788 KB |
Output is correct |
17 |
Correct |
104 ms |
11856 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
2370 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
99 ms |
40328 KB |
Output is correct |
3 |
Correct |
98 ms |
40052 KB |
Output is correct |
4 |
Correct |
92 ms |
38248 KB |
Output is correct |
5 |
Execution timed out |
5053 ms |
78196 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
1078 ms |
115744 KB |
Output is correct |
3 |
Runtime error |
1704 ms |
524292 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
1078 ms |
115744 KB |
Output is correct |
3 |
Runtime error |
1704 ms |
524292 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
1078 ms |
115744 KB |
Output is correct |
3 |
Runtime error |
1704 ms |
524292 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Runtime error |
1616 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
42 ms |
15648 KB |
Output is correct |
3 |
Correct |
68 ms |
22808 KB |
Output is correct |
4 |
Correct |
2 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
5 ms |
1556 KB |
Output is correct |
10 |
Correct |
0 ms |
388 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 |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
26 ms |
8808 KB |
Output is correct |
16 |
Correct |
29 ms |
8788 KB |
Output is correct |
17 |
Correct |
104 ms |
11856 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Runtime error |
2370 ms |
524288 KB |
Execution killed with signal 9 |
21 |
Halted |
0 ms |
0 KB |
- |