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"
using namespace std;
#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, q;
cin >> n >> q;
vector<long long> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
for (int i = 1; i < n; ++i) {
if (a[i] < a[i - 1]) {
a[i] = a[i - 1];
} else {
a[i] = ((a[i] + a[i - 1] - 1) / a[i - 1]) * a[i - 1];
}
}
while (q--) {
int t, l, r;
cin >> t >> l >> r;
int ans = t >= l && t <= r;
for (int i = 0; i < n; ++i) {
int p = t / a[i] * a[i] - i - 1;
ans += p >= l && p <= r;
}
cout << ans << '\n';
}
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... |