이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1000000000000000000
#define MOD 998244353
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, q, t, l, r;
    cin >> n >> q;
    int a[n+1];
    a[0] = 1;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] = (a[i]+a[i-1]-1)/a[i-1]*a[i-1];
    }
    while(q--) {
        cin >> t >> l >> r;
        int L = 0, R = n+1, m;
        while(L < R) {
            m = (L+R)/2;
            int pos = -m+t/a[m]*a[m];
            if(pos > r) L = m+1;
            else R = m;
        }
        int rpos = L;
        L = 0; R = n+1;
        while(L < R) {
            m = (L+R)/2;
            int pos = -m+t/a[m]*a[m];
            if(pos >= l) L = m+1;
            else R = m;
        }
        int lpos = L;
        cout << lpos-rpos << '\n';
    }
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |