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 <iostream>
using namespace std;
long long n, test, a[500010], b[500010], ll, rr, tim, l, r, mid, tmp;
int main() {
cin >> n >> test;
for (int i = 1; i <= n; i++) cin >> a[i];
b[0] = 1;
for (int i = 1; i <= n; i++) b[i] = (a[i]+b[i-1]-1)/b[i-1]*b[i-1];
while (test--) {
cin >> tim >> ll >> rr;
l = 0; r = n;
while (l <= r) {
mid = (l+r)/2;
if ((tim/b[mid])*b[mid]-mid >= ll) l = mid+1;
else r = mid-1;
}
tmp = r;
l = 0; r = n;
while (l <= r) {
mid = (l+r)/2;
if ((tim/b[mid])*b[mid]-mid <= rr) r = mid-1;
else l = mid+1;
}
cout << tmp-r << 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... |