結果
問題 | No.2758 RDQ |
ユーザー |
|
提出日時 | 2024-05-17 21:27:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 131 ms / 2,000 ms |
コード長 | 904 bytes |
コンパイル時間 | 1,806 ms |
コンパイル使用メモリ | 197,928 KB |
最終ジャッジ日時 | 2025-02-21 14:30:55 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;template<class T> istream& operator >> (istream& is, vector<T>& vec) {for(T& x : vec) is >> x;return is;}int main(){ios::sync_with_stdio(false);cin.tie(0);int n, q;cin >> n >> q;const int m = 100000;vector<vector<int>> tb(m + 1);vector<vector<int>> S(m + 1);for(int i = 1; i <= m; i++){for(int j = i; j <= m; j += i){tb[j].emplace_back(i);}}for(int i = 0; i < n; i++){int v;cin >> v;for(auto &&v2 : tb[v]){S[v2].emplace_back(i);}}while(q--){int l, r, v;cin >> l >> r >> v;l--;l = lower_bound(S[v].begin(), S[v].end(), l) - tb[v].begin();r = lower_bound(S[v].begin(), S[v].end(), r) - tb[v].begin();cout << r - l << '\n';}}