結果
問題 |
No.2758 RDQ
|
ユーザー |
|
提出日時 | 2024-05-17 21:33:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 104 ms / 2,000 ms |
コード長 | 681 bytes |
コンパイル時間 | 1,933 ms |
コンパイル使用メモリ | 197,136 KB |
最終ジャッジ日時 | 2025-02-21 14:35:23 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,Q; cin >> N >> Q; vector<vector<int>> ap(100001); for(int i=0; i<N; i++){ int a; cin >> a; for(int k=1; k*k<=a; k++){ if(a%k) continue; ap.at(k).push_back(i); if(k*k != a) ap.at(a/k).push_back(i); } } while(Q--){ int l,r,k; cin >> l >> r >> k; l--; r--; int posl = lower_bound(ap.at(k).begin(),ap.at(k).end(),l)-ap.at(k).begin(); int posr = upper_bound(ap.at(k).begin(),ap.at(k).end(),r)-ap.at(k).begin(); cout << posr-posl << "\n"; } }