#include <bits/stdc++.h>
using namespace std;
#define Baytoro_Mayrambekov void solve()
#define ios ios::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define int long long
#define endl '\n'
const int INF=1e18;
void fopn(string name){
freopen((name+".in").c_str(),"r",stdin);
freopen((name+".out").c_str(),"w",stdout);
}
int binpow(int a,int n){
if(n==0)
return 1;
if(n%2==1)
return binpow(a, n-1)*a;
else{
int b=binpow(a, n/2);
return b*b;
}
}
int a,b,c,n,m,i,j,k,x,y,cnt=0,sum=0,res=0;
Baytoro_Mayrambekov{
cin>>n>>a>>b;
int mx=a/(__gcd(a,b+1))*b;
set<pair<int,int>> st;
for(i=0;i<n;i++){
int l,r;
cin>>l>>r;
if(r-l+1>=mx){
cout<<mx<<endl;
return;
}
for(j=l;j<=r;j++){
st.insert({(j+j/b)%a,j%b});
}
}
cout<<st.size();
}
main(){
ios;
int T=1;
//cin>>T;
while(T--){
solve();
}
}
Compilation message
strange_device.cpp:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
46 | main(){
| ^~~~
strange_device.cpp: In function 'void fopn(std::string)':
strange_device.cpp:14:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | freopen((name+".in").c_str(),"r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:15:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | freopen((name+".out").c_str(),"w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
44 ms |
12704 KB |
Output is correct |
3 |
Correct |
62 ms |
18256 KB |
Output is correct |
4 |
Correct |
2 ms |
852 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
7 ms |
1124 KB |
Output is correct |
10 |
Correct |
1 ms |
320 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
316 KB |
Output is correct |
14 |
Correct |
1 ms |
320 KB |
Output is correct |
15 |
Correct |
42 ms |
6972 KB |
Output is correct |
16 |
Correct |
30 ms |
7100 KB |
Output is correct |
17 |
Correct |
60 ms |
10248 KB |
Output is correct |
18 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
320 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Runtime error |
2574 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
131 ms |
32236 KB |
Output is correct |
3 |
Correct |
176 ms |
32020 KB |
Output is correct |
4 |
Correct |
133 ms |
30584 KB |
Output is correct |
5 |
Execution timed out |
5017 ms |
62528 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
585 ms |
77544 KB |
Output is correct |
3 |
Runtime error |
1742 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
585 ms |
77544 KB |
Output is correct |
3 |
Runtime error |
1742 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
585 ms |
77544 KB |
Output is correct |
3 |
Runtime error |
1742 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
1379 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
44 ms |
12704 KB |
Output is correct |
3 |
Correct |
62 ms |
18256 KB |
Output is correct |
4 |
Correct |
2 ms |
852 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
7 ms |
1124 KB |
Output is correct |
10 |
Correct |
1 ms |
320 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
316 KB |
Output is correct |
14 |
Correct |
1 ms |
320 KB |
Output is correct |
15 |
Correct |
42 ms |
6972 KB |
Output is correct |
16 |
Correct |
30 ms |
7100 KB |
Output is correct |
17 |
Correct |
60 ms |
10248 KB |
Output is correct |
18 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |