結果

問題 No.2758 RDQ
ユーザー futamegawa
提出日時 2024-05-17 23:29:11
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 633 bytes
コンパイル時間 3,288 ms
コンパイル使用メモリ 246,828 KB
実行使用メモリ 17,984 KB
最終ジャッジ日時 2024-12-20 15:31:03
合計ジャッジ時間 55,465 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 TLE * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using llu = long long unsigned;

#define MOD 100000000
int main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (auto &y : a) { cin >> y; }
    vector<int> l(q), r(q), k(q);
    for (int i=0; i<q; ++i) {
        cin >> l[i] >> r[i] >> k[i];
    }

    vector<int> tmp(n+1);
    for (int i=0; i<q; ++i) {
        tmp.clear();
        for (int j=1; j<=n; ++j) {
            tmp[j] = tmp[j-1];
            if (a[j-1]%k[i]==0) { tmp[j]++; }
        }
        int count = tmp[r[i]] - tmp[l[i]-1];
        cout << count << endl;
    }
    return 0;
}
0