結果

問題 No.854 公平なりんご分配
ユーザー DAyamaCTFDAyamaCTF
提出日時 2019-07-27 08:31:21
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,991 bytes
コンパイル時間 1,313 ms
コンパイル使用メモリ 150,460 KB
実行使用メモリ 244,164 KB
最終ジャッジ日時 2023-09-15 05:55:12
合計ジャッジ時間 34,861 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,856 KB
testcase_01 AC 3 ms
5,756 KB
testcase_02 AC 3 ms
5,928 KB
testcase_03 AC 3 ms
5,936 KB
testcase_04 AC 4 ms
5,744 KB
testcase_05 AC 3 ms
5,764 KB
testcase_06 AC 4 ms
5,928 KB
testcase_07 AC 4 ms
5,928 KB
testcase_08 AC 4 ms
5,820 KB
testcase_09 AC 3 ms
5,748 KB
testcase_10 AC 3 ms
6,056 KB
testcase_11 AC 4 ms
5,768 KB
testcase_12 AC 4 ms
5,912 KB
testcase_13 AC 4 ms
5,860 KB
testcase_14 AC 3 ms
5,744 KB
testcase_15 AC 3 ms
5,852 KB
testcase_16 AC 4 ms
5,904 KB
testcase_17 AC 4 ms
5,968 KB
testcase_18 AC 4 ms
5,908 KB
testcase_19 AC 4 ms
6,032 KB
testcase_20 AC 4 ms
5,860 KB
testcase_21 AC 4 ms
5,860 KB
testcase_22 AC 9 ms
6,160 KB
testcase_23 AC 10 ms
6,944 KB
testcase_24 AC 16 ms
7,836 KB
testcase_25 AC 9 ms
6,772 KB
testcase_26 AC 17 ms
7,928 KB
testcase_27 AC 14 ms
7,912 KB
testcase_28 AC 9 ms
6,212 KB
testcase_29 AC 6 ms
6,136 KB
testcase_30 AC 9 ms
6,676 KB
testcase_31 AC 15 ms
7,540 KB
testcase_32 AC 206 ms
55,984 KB
testcase_33 AC 169 ms
32,536 KB
testcase_34 AC 348 ms
75,088 KB
testcase_35 AC 256 ms
60,244 KB
testcase_36 AC 107 ms
8,796 KB
testcase_37 AC 195 ms
52,900 KB
testcase_38 AC 154 ms
44,004 KB
testcase_39 AC 461 ms
79,392 KB
testcase_40 AC 179 ms
28,900 KB
testcase_41 AC 231 ms
49,460 KB
testcase_42 AC 321 ms
73,948 KB
testcase_43 AC 316 ms
51,448 KB
testcase_44 AC 361 ms
68,900 KB
testcase_45 AC 250 ms
17,732 KB
testcase_46 AC 433 ms
68,000 KB
testcase_47 AC 181 ms
40,164 KB
testcase_48 AC 305 ms
72,944 KB
testcase_49 AC 297 ms
74,308 KB
testcase_50 AC 186 ms
52,584 KB
testcase_51 AC 429 ms
71,160 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 AC 1,463 ms
243,832 KB
testcase_84 AC 1,444 ms
243,836 KB
testcase_85 AC 1,506 ms
243,844 KB
testcase_86 AC 1,090 ms
243,836 KB
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 1,541 ms
243,888 KB
testcase_93 AC 1,547 ms
244,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

vector<ll> operator+(const vector<ll>& a,const vector<ll>& b){
  vector<ll> res(a.size(),0);
  rep(i,a.size())res[i]=a[i]+b[i];
  return res;
}
vector<ll> operator-(const vector<ll>& a,const vector<ll>& b){
  vector<ll> res(a.size(),0);
  rep(i,a.size())res[i]=a[i]-b[i];
  return res;
}

bool isprime[2001];
vector<ll> ps;
ll M;
vector<ll> calcvec(ll X){
  if(X==0) return vector<ll>(M,0);

  vector<ll> res(M,0);
  rep(i,ps.size()){
    while(X%ps[i]==0){
      res[i]++;
      X/=ps[i];
    }
  }
  if(X!=1) return vector<ll>(1,-1);
  return res;
}

ll N,Q;
vector<ll> sum[100010];
ll zsum[100010];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  repl(i,2,2001)isprime[i]=true;
  for(ll i=2;i<=2000;i++){
    if(isprime[i]){
      ps.push_back(i);
      for(ll j=i*2;j<=2000;j+=i)isprime[j]=false;
    }
  }
  M=ps.size();

  sum[0]=vector<ll>(M,0);
  cin>>N;
  rep(i,N){
    ll A;
    cin>>A;
    if(A==0){
      zsum[i+1]=zsum[i]+1;
    }else{
      zsum[i+1]=zsum[i];
    }
    vector<ll> B=calcvec(A);
    sum[i+1]=sum[i]+B;
  }

  cin>>Q;
  rep(i,Q){
    ll P,L,R;
    cin>>P>>L>>R;
    L--;
    vector<ll> tmp=sum[R]-sum[L];
    vector<ll> p=calcvec(P);
    if(p[0]==-1){
      cout<<"NO"<<endl;
      continue;
    }
    bool ok=true;
    rep(j,M)if(tmp[j]<p[j])ok=false;
    if(ok||zsum[R]-zsum[L]>0) cout<<"Yes"<<endl;
    else cout<<"NO"<<endl;
  }

  return 0;
}
0