#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb emplace_back
#define ins insert
#define f first
#define s second
#define db 0
#define EPS (1e-7) //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph emplace
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, q, A[MAXN], mi[MAXN]; // mi - stands for mini place IOI-chan has to be, in order for him to move up
int main()
{
FAST
cin>>n>>q;
FOR(i,1,n+1)cin>>A[i];
mi[0]=1;
FOR(i,1,n+1) { // now we calculate mi[i]; - based on mi[i-1];
mi[i] = (((A[i] - 1)/mi[i-1]+1)*mi[i-1]); cerr<<mi[i]<<'\n';
}
FOR(i,0,q) {
ll t,l,r;cin>>t>>l>>r;
ll st = 0, en = n+1, mid = 0;
while(en-st>1) {
mid=(st+en)>>1ll;
if(t/mi[mid]*mi[mid]-mid >= l) st=mid;
else en=mid;
}
ll ans1 = st;
st=0,en=n+1,mid=0;
while(en-st>1) {
mid=(st+en)>>1ll;
if(t/mi[mid]*mi[mid]-mid>r)st=mid;
else en=mid;
}
ll ans2=st;
// cerr << ans1 << " " << ans2 << ' ' << t << ' ' << mi[1] << ' ';
cout<<ans1-ans2+(l<=t&&t<=r)<<'\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
21 ms |
3456 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
21 ms |
3456 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |