結果
| 問題 |
No.2758 RDQ
|
| コンテスト | |
| ユーザー |
Yudai0606Nazo
|
| 提出日時 | 2024-05-18 05:22:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 213 ms / 2,000 ms |
| コード長 | 1,555 bytes |
| コンパイル時間 | 4,350 ms |
| コンパイル使用メモリ | 257,244 KB |
| 最終ジャッジ日時 | 2025-02-21 15:36:59 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
#include <cassert>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
//using mint = modint1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repu(i, s, t) for (int i = (int)(s); i < (int)(t); i++)
#define repd(i, s, t) for (int i = (int)(s)-1; i >= (int)(t); i--)
#define all(v) v.begin(), v.end()
template<typename T> bool chmax(T &a, const T b) { if(a >= b) return false; a = b; return true; }
template<typename T> bool chmin(T &a, const T b) { if(a <= b) return false; a = b; return true; }
template<typename T> istream& operator>>(istream &in, vector<T> &a) { for(T &x: a) in >> x; return in; }
template<typename T> ostream& operator<<(ostream &out, const vector<T> &a) { for(const T &x: a) out << x << ' '; return out; }
const int di[] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
const int dj[] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int main() {
int n, q;
cin >> n >> q;
vector<int> a(n);
cin >> a;
vector<int> l(q), r(q), k(q);
rep(i, q) {
cin >> l[i] >> r[i] >> k[i];
l[i]--;
}
unordered_map<int, vector<int>> divs;
rep(i, n) {
for(int j = 1; j * j <= a[i]; j++) {
if(a[i] % j != 0) continue;
divs[j].push_back(i);
if(j*j == a[i]) break;
divs[a[i]/j].push_back(i);
}
}
rep(qi, q) {
auto &v = divs[k[qi]];
cout << lower_bound(all(v), r[qi]) - lower_bound(all(v), l[qi]) << '\n';
}
return 0;
}
Yudai0606Nazo