This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;
const int mxn=1e5+5;
const int inf=1e9;
int main() {
int n,q;
cin >> n >> q;
ll d[n + 1];
for(int i = 1; i <= n; i++) cin >> d[i];
ll jump[n + 2];
jump[0] = 1;
for(int i = 1; i <= n; i++) {
jump[i] = jump[i - 1] * ((d[i] + jump[i - 1] - 1) / jump[i - 1]);
}
while(q--) {
ll t,l,r;
cin >> t >> l >> r;
int ans = 0;
for(int i = 1; i <= n; i++) {
ll x = t / jump[i];
ll p = -i + x * jump[i];
if(p >= l && p <= r) ans++;
}
if(t >= l && t <= r) ans++;
cout<<ans<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |