#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll MOD=1e9+7;
const ll N=2e5+5;
const ld pi=3.14159265359;
const ll INF=(1LL<<62);
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()
ll T,L,R,n,q,l[N],d[N],t[N];
ll cal(ll tid,ll range){
ll ql=-1,qr=n+1;
while(qr-ql>1){
ll mid=(ql+qr)/2;
if(tid/t[mid]*l[mid]-mid>range){
ql=mid;
}else{
qr=mid;
}
}
return (n+1-qr);
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>q;
l[0]=t[0]=1;
REP1(i,n)cin>>d[i];
REP1(i,n){
l[i]=((d[i]+l[i-1]-1)/l[i-1])*l[i-1];
t[i]=t[i-1]*((d[i]+l[i-1]-1)/l[i-1]);
if(t[i]>1e9){n=i;break;}
}
while(q--){
cin>>T>>L>>R;
//cout<<cal(T,R)<<" "<<cal(T,L-1)<<"\n";
cout<<cal(T,R)-cal(T,L-1)<<"\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
4480 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
4480 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |