結果

問題 No.854 公平なりんご分配
ユーザー 👑 tute7627tute7627
提出日時 2019-07-26 22:39:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,664 bytes
コンパイル時間 1,535 ms
コンパイル使用メモリ 163,256 KB
実行使用メモリ 813,628 KB
最終ジャッジ日時 2023-09-15 02:39:05
合計ジャッジ時間 60,971 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
4,384 KB
testcase_01 AC 22 ms
4,380 KB
testcase_02 AC 22 ms
4,380 KB
testcase_03 AC 22 ms
4,380 KB
testcase_04 AC 22 ms
4,380 KB
testcase_05 AC 23 ms
4,380 KB
testcase_06 AC 22 ms
4,376 KB
testcase_07 AC 23 ms
4,380 KB
testcase_08 AC 23 ms
4,376 KB
testcase_09 AC 23 ms
4,376 KB
testcase_10 AC 23 ms
4,380 KB
testcase_11 AC 22 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 23 ms
4,376 KB
testcase_15 AC 23 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 24 ms
4,476 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 MLE -
testcase_33 WA -
testcase_34 MLE -
testcase_35 MLE -
testcase_36 WA -
testcase_37 MLE -
testcase_38 WA -
testcase_39 MLE -
testcase_40 WA -
testcase_41 MLE -
testcase_42 MLE -
testcase_43 MLE -
testcase_44 MLE -
testcase_45 WA -
testcase_46 MLE -
testcase_47 WA -
testcase_48 MLE -
testcase_49 MLE -
testcase_50 MLE -
testcase_51 MLE -
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 MLE -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 MLE -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 MLE -
testcase_74 MLE -
testcase_75 WA -
testcase_76 MLE -
testcase_77 MLE -
testcase_78 WA -
testcase_79 MLE -
testcase_80 MLE -
testcase_81 MLE -
testcase_82 MLE -
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 long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
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(ll n){ 
  ll buf=n;
  map<ll,ll>ret;
  ll i,j;
  for(i=2;buf!=1&&i*i<=n;i++){
    for(j=0;buf%i==0;j++){
      buf/=i;
    }
    if(i>0)ret.emplace(i,j);
  }
  if(buf!=1)ret.emplace(buf,1);
  return ret;
}

int main(){
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  ll q;cin>>q;
  vector<ll>p(q),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(judge)cout<<"Yes"<<endl;
    else cout<<"NO"<<endl;
  }
  
  return 0;
}
0