#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> bool maximize(T &a, const T &b){ return (a < b ? a = b, 1 : 0); }
template<class T> bool minimize(T &a, const T &b){ return (a > b ? a = b, 1 : 0); }
#define fi first
#define se second
#define pb push_back
#define ii pair<int, int>
#define all(x) x.begin(), x.end()
#define TASK "nonsense"
/// end of template ///
const int Q = 1e6 + 10;
ll S=0,L=0,A,B;
int _q;
pair<ll,ll> q[Q];
namespace sub1
{
bool check()
{
return (S<=(int)1e6);
}
set<pair<ll,ll>> s;
void solve()
{
for(int i=1;i<=_q;++i)
{
for(ll t=q[i].fi;t<=q[i].se;++t) s.insert({(t+t/B)%A,t%B});
}
cout<<(int)s.size();
}
}
void solve()
{
cin>>_q>>A>>B;
for(int i=1;i<=_q;++i)
{
ll l,r; cin>>l>>r;
q[i]={l,r};
maximize(L,r-l+1);
S+=r-l+1;
}
if(sub1::check()) return void(sub1::solve());
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen(TASK".inp","r",stdin);
// freopen(TASK".out","w",stdout);
int testcase=1;
// cin>>testcase;
while (testcase--)
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |