結果
問題 | No.2758 RDQ |
ユーザー |
![]() |
提出日時 | 2024-05-17 21:33:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 212 ms / 2,000 ms |
コード長 | 649 bytes |
コンパイル時間 | 751 ms |
コンパイル使用メモリ | 78,868 KB |
最終ジャッジ日時 | 2025-02-21 14:35:29 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>using namespace std;int main(){int n, q;cin >> n >> q;vector<int> a(n);for (int i = 0; i < n; ++i) cin >> a[i];vector<vector<int>> id(1e5 + 1);for (int i = 0; i < n; ++i){for (int j = 1; j * j <= a[i]; ++j){if (a[i] % j) continue;int v1 = j, v2 = a[i] / j;id[v1].push_back(i);if (v1 != v2) id[v2].push_back(i);}}while (q--){int l, r, k;cin >> l >> r >> k;--l, --r;int ans = upper_bound(id[k].begin(), id[k].end(), r) - lower_bound(id[k].begin(), id[k].end(), l);cout << ans << endl;}}