結果

問題 No.854 公平なりんご分配
ユーザー DAyamaCTFDAyamaCTF
提出日時 2019-07-27 08:27:23
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,013 bytes
コンパイル時間 1,282 ms
コンパイル使用メモリ 149,928 KB
実行使用メモリ 126,572 KB
最終ジャッジ日時 2023-09-15 05:54:30
合計ジャッジ時間 23,598 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,832 KB
testcase_01 AC 3 ms
6,004 KB
testcase_02 AC 4 ms
5,744 KB
testcase_03 AC 4 ms
5,736 KB
testcase_04 AC 3 ms
5,724 KB
testcase_05 AC 4 ms
5,788 KB
testcase_06 AC 3 ms
5,740 KB
testcase_07 AC 3 ms
5,932 KB
testcase_08 AC 4 ms
5,752 KB
testcase_09 AC 3 ms
5,744 KB
testcase_10 AC 4 ms
5,852 KB
testcase_11 AC 4 ms
5,804 KB
testcase_12 AC 4 ms
5,884 KB
testcase_13 AC 4 ms
5,860 KB
testcase_14 AC 3 ms
5,736 KB
testcase_15 AC 3 ms
5,764 KB
testcase_16 AC 4 ms
5,820 KB
testcase_17 AC 4 ms
5,896 KB
testcase_18 AC 4 ms
5,816 KB
testcase_19 AC 4 ms
5,796 KB
testcase_20 AC 3 ms
5,836 KB
testcase_21 AC 4 ms
5,988 KB
testcase_22 AC 7 ms
5,904 KB
testcase_23 AC 7 ms
6,236 KB
testcase_24 AC 10 ms
6,728 KB
testcase_25 AC 6 ms
6,156 KB
testcase_26 AC 11 ms
6,728 KB
testcase_27 AC 10 ms
6,728 KB
testcase_28 AC 7 ms
5,848 KB
testcase_29 AC 5 ms
6,104 KB
testcase_30 AC 6 ms
6,168 KB
testcase_31 AC 10 ms
6,624 KB
testcase_32 AC 109 ms
31,140 KB
testcase_33 AC 98 ms
19,324 KB
testcase_34 AC 192 ms
40,824 KB
testcase_35 AC 139 ms
33,296 KB
testcase_36 AC 65 ms
7,316 KB
testcase_37 AC 103 ms
29,516 KB
testcase_38 AC 82 ms
25,112 KB
testcase_39 AC 262 ms
43,080 KB
testcase_40 AC 105 ms
17,480 KB
testcase_41 AC 130 ms
27,696 KB
testcase_42 AC 173 ms
40,224 KB
testcase_43 AC 183 ms
28,796 KB
testcase_44 AC 200 ms
37,580 KB
testcase_45 AC 159 ms
11,736 KB
testcase_46 AC 247 ms
37,336 KB
testcase_47 AC 102 ms
23,128 KB
testcase_48 AC 164 ms
39,624 KB
testcase_49 AC 157 ms
40,700 KB
testcase_50 AC 97 ms
29,340 KB
testcase_51 AC 247 ms
38,772 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 795 ms
126,296 KB
testcase_84 AC 794 ms
126,256 KB
testcase_85 AC 816 ms
126,244 KB
testcase_86 AC 653 ms
126,460 KB
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 870 ms
126,260 KB
testcase_93 AC 876 ms
126,256 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<int> operator+(const vector<int>& a,const vector<int>& b){
  vector<int> res(a.size(),0);
  rep(i,a.size())res[i]=a[i]+b[i];
  return res;
}
vector<int> operator-(const vector<int>& a,const vector<int>& b){
  vector<int> res(a.size(),0);
  rep(i,a.size())res[i]=a[i]-b[i];
  return res;
}

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

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

int N,Q;
vector<int> sum[100010];
int 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<int>(M,0);
  cin>>N;
  rep(i,N){
    int A;
    cin>>A;
    if(A==0){
      zsum[i+1]=zsum[i]+1;
    }else{
      zsum[i+1]=zsum[i];
    }
    vector<int> B=calcvec(A);
    sum[i+1]=sum[i]+B;
  }

  cin>>Q;
  rep(i,Q){
    int P,L,R;
    cin>>P>>L>>R;
    L--;
    vector<int> tmp=sum[R]-sum[L];
    vector<int> 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]) cout<<"Yes"<<endl;
    else cout<<"NO"<<endl;
  }

  return 0;
}
0