結果

問題 No.2758 RDQ
ユーザー たたき@競プロ
提出日時 2024-05-18 13:22:57
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 755 bytes
コンパイル時間 5,453 ms
コンパイル使用メモリ 310,244 KB
実行使用メモリ 17,152 KB
最終ジャッジ日時 2024-12-20 16:22:30
合計ジャッジ時間 10,038 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint998244353; //1000000007;
using ll=long long;
using pp=pair<int,int>;
#define sr string 
#define vc vector
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int main(){
  int n,q;cin>>n>>q;
  int m=1e5+1;
  vc v(m,vc<int>(0));
  rep(i,n){
    int a;cin>>a;
    for(int j=1;j*j<=a;j++)if(a%j==0){
      v[j].pb(i);
      if(j!=a/j)v[a/j].pb(i);
    }
  }
  rep(i,q){
    int l,r,x;cin>>l>>r>>x;
    l--;
    int ans=lower_bound(all(v[x]),r)-lower_bound(all(v[x]),l);
    cout<<ans<<"\n";
  }
}
      
0