#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
cerr<<vars<<" = ";
string delim="";
(...,(cerr<<delim<<values,delim=", "));
cerr<<"\n";
}
#else
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {}
#endif
#define pb push_back
#define sz(x) (int)(x.size())
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> inline void maxa(T& a,T b){a=max(a,b);}
template<typename T> inline void mina(T& a,T b){a=min(a,b);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mxN=2e5+5; //make sure this is right
const int mod=1e9+7;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
int main(){
cin.sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifdef LOCAL
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
int n; cin>>n;
ll a,b; cin>>a>>b;
set<pll> seen;
if(n==1){
ll l,r; cin>>l>>r;
if(b<a)
assert(false);
cout<<min(r-l+1,a*b)<<"\n";
} else{
for(int i=0;i<n;i++){
ll l,r; cin>>l>>r;
for(ll j=l;j<=r;j++){
seen.insert({(j%a+(j/b)%a)%a,j%b});
}
}
cout<<sz(seen)<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
52 ms |
12320 KB |
Output is correct |
3 |
Correct |
75 ms |
17924 KB |
Output is correct |
4 |
Correct |
2 ms |
844 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
9 ms |
1100 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
304 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
53 ms |
6940 KB |
Output is correct |
16 |
Correct |
39 ms |
6628 KB |
Output is correct |
17 |
Correct |
78 ms |
6536 KB |
Output is correct |
18 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
155 ms |
32388 KB |
Output is correct |
3 |
Correct |
197 ms |
32084 KB |
Output is correct |
4 |
Correct |
154 ms |
30552 KB |
Output is correct |
5 |
Execution timed out |
5095 ms |
62476 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
634 ms |
62912 KB |
Output is correct |
3 |
Runtime error |
2232 ms |
524292 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
634 ms |
62912 KB |
Output is correct |
3 |
Runtime error |
2232 ms |
524292 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
634 ms |
62912 KB |
Output is correct |
3 |
Runtime error |
2232 ms |
524292 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Runtime error |
1840 ms |
524292 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
52 ms |
12320 KB |
Output is correct |
3 |
Correct |
75 ms |
17924 KB |
Output is correct |
4 |
Correct |
2 ms |
844 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
9 ms |
1100 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
304 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
53 ms |
6940 KB |
Output is correct |
16 |
Correct |
39 ms |
6628 KB |
Output is correct |
17 |
Correct |
78 ms |
6536 KB |
Output is correct |
18 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |