結果
| 問題 |
No.2758 RDQ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-17 21:31:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 309 ms / 2,000 ms |
| コード長 | 2,854 bytes |
| コンパイル時間 | 2,025 ms |
| コンパイル使用メモリ | 200,868 KB |
| 最終ジャッジ日時 | 2025-02-21 14:34:07 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forin(in ,n) for(ll i=0; i<n; i++) cin>>in[i]
#define forout(out) for(ll i=0; i<(ll)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep_up(i, a, n) for (ll i = a; i < n; ++i)
#define rep_down(i, a, n) for (ll i = a; i >= n; --i)
#define P pair<ll, ll>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>
#define pqll priority_queue<ll>
#define pqllg priority_queue<ll, vector<ll>, greater<ll>>
constexpr ll INF = (1ll << 60);
constexpr ll mod = 1000000007;
//constexpr ll mod = 998244353;
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <typename T>
void pt(T val) {
cout << val << "\n";
}
template <typename T>
void pt_vll(vector<T> &v) {
ll vs = v.size();
rep(i, vs) {
cout << v[i];
if (i == vs - 1)
cout << "\n";
else
cout << " ";
}
}
ll mypow(ll a, ll n) {
ll ret = 1;
if(n==0) return 1;
if(a==0) return 0;
rep(i, n) {
if (ret > (ll)(1e18 + 10) / a) return -1;
ret *= a;
}
return ret;
}
long long modpow(long long a, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1) res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
long long modinv(long long a, long long m) {
long long b = m, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
u %= m;
if (u < 0) u += m;
return u;
}
ll digsum(ll n) {
ll res = 0;
while(n > 0) {
res += n%10;
n /= 10;
}
return res;
}
vector<ll> enum_div(ll n){ //約数全列挙
vector<ll> ret;
for(ll i = 1 ; i*i <= n ; ++i){
if(n%i == 0){
ret.push_back(i);
if(i*i != n){
ret.push_back(n/i);
}
}
}
return ret;
}
int main() {
ll n,m,q,x,l,r,k,ans=1;
cin>>n;cin>>q;
vector<ll> a(n);
vll p;
vvll st(100001);
rep(i,n){
cin>>x;
a[i]=x;
}
rep(i,n){
p=enum_div(a[i]);
for(auto e:p){
st[e].push_back(i);
}
}
rep(i,q){
cin>>l>>r>>x;
k=upper_bound(all(st[x]),r-1)-lower_bound(all(st[x]),l-1);
cout<<k<<endl;
}
}
// https://mojacoder.app/users/heabi/problems/Range-Divisible-Query/submissions/b1998929-3332-4586-83bc-c938ce75b90a