結果

問題 No.854 公平なりんご分配
ユーザー 👑 tute7627tute7627
提出日時 2019-07-26 23:26:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,773 bytes
コンパイル時間 1,579 ms
コンパイル使用メモリ 164,376 KB
実行使用メモリ 304,548 KB
最終ジャッジ日時 2023-09-15 04:59:14
合計ジャッジ時間 12,531 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,380 KB
testcase_01 AC 9 ms
4,376 KB
testcase_02 AC 9 ms
4,380 KB
testcase_03 AC 9 ms
4,376 KB
testcase_04 AC 8 ms
4,380 KB
testcase_05 AC 9 ms
4,376 KB
testcase_06 AC 9 ms
4,380 KB
testcase_07 AC 9 ms
4,376 KB
testcase_08 AC 9 ms
4,380 KB
testcase_09 AC 9 ms
4,376 KB
testcase_10 AC 9 ms
4,380 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 12 ms
4,620 KB
testcase_13 AC 12 ms
4,556 KB
testcase_14 AC 9 ms
4,376 KB
testcase_15 AC 9 ms
4,376 KB
testcase_16 AC 12 ms
4,684 KB
testcase_17 AC 13 ms
4,896 KB
testcase_18 AC 11 ms
4,380 KB
testcase_19 AC 11 ms
4,416 KB
testcase_20 AC 11 ms
4,380 KB
testcase_21 AC 11 ms
4,380 KB
testcase_22 AC 20 ms
6,528 KB
testcase_23 AC 35 ms
11,652 KB
testcase_24 AC 51 ms
16,784 KB
testcase_25 AC 29 ms
9,820 KB
testcase_26 WA -
testcase_27 AC 52 ms
17,504 KB
testcase_28 AC 20 ms
6,444 KB
testcase_29 AC 19 ms
6,800 KB
testcase_30 AC 27 ms
9,412 KB
testcase_31 AC 46 ms
15,556 KB
testcase_32 AC 992 ms
304,548 KB
testcase_33 AC 569 ms
164,452 KB
testcase_34 TLE -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n; i < (ll)(m); i--)
typedef short ll;
typedef long double ld;
const ll MOD = 50003;
//const ll INF = 1e18;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
void debug(vector<ll>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->second++;
map<ll,ll> factoring(int n){ 
  int buf=n;
  map<ll,ll>ret;
  ll i,j;
  for(i=2;buf!=1&&i<=2000&&i*i<=n;i++){
    for(j=0;buf%i==0;j++){
      buf/=i;
    }
    if(j>0)ret.emplace(i,j);
  }
  if(buf!=1)ret.emplace(min(buf,50000),1);
  return ret;
}

int main(){
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  vector<ll>b(n+1);
  rep(i,0,n){
    cin>>a[i];
    if(a[i]==0)b[i+1]=b[i]+1;
    else b[i+1]=b[i];
  }
  ll q;cin>>q;
  vector<short>p(q);
  vector<ll>l(q),r(q);
  rep(i,0,q)cin>>p[i]>>l[i]>>r[i];
  vector<map<ll,ll>>v(n+1);
  rep(i,2,2001){
    judge=true;
    rep(j,2,i-1)if(i%j==0)judge=false;
    if(judge)v[0].emplace(i,0);
  }
  rep(i,0,n){
    auto m=factoring(a[i]);
    for(auto z:v[i]){
      if(m.find(z.fi)!=m.end()){
        v[i+1].emplace(z.fi,z.se+m[z.fi]);
      }
      else v[i+1].emplace(z.fi,z.se);
    }
  }
  rep(i,0,q){
    auto m=factoring(p[i]);
    judge=true;
    for(auto z:m){
      //cout<<z.fi spa z.se<<endl;
      if(v[l[i]-1].find(z.fi)==v[l[i]-1].end()){
        judge=false;break;
      }
      else{
        if(v[r[i]][z.fi]-v[l[i]-1][z.fi]<z.se){
          judge=false;break;
        }
      }
    }
    if(b[l[i]-1]!=b[r[i]])judge=true;
    if(judge)cout<<"Yes"<<endl;
    else cout<<"NO"<<endl;
  }
  
  return 0;
}
0