結果

問題 No.854 公平なりんご分配
ユーザー 👑 tute7627tute7627
提出日時 2019-07-26 23:11:07
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 2,762 bytes
コンパイル時間 1,492 ms
コンパイル使用メモリ 162,792 KB
実行使用メモリ 445,500 KB
最終ジャッジ日時 2023-09-15 04:13:49
合計ジャッジ時間 30,323 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
8,760 KB
testcase_01 AC 8 ms
4,376 KB
testcase_02 AC 8 ms
4,376 KB
testcase_03 AC 8 ms
4,380 KB
testcase_04 AC 8 ms
4,376 KB
testcase_05 AC 8 ms
4,376 KB
testcase_06 AC 8 ms
4,376 KB
testcase_07 AC 8 ms
4,376 KB
testcase_08 AC 8 ms
4,376 KB
testcase_09 AC 8 ms
4,376 KB
testcase_10 AC 8 ms
4,380 KB
testcase_11 AC 8 ms
4,376 KB
testcase_12 AC 11 ms
4,484 KB
testcase_13 AC 11 ms
4,416 KB
testcase_14 AC 8 ms
4,380 KB
testcase_15 AC 9 ms
4,376 KB
testcase_16 AC 11 ms
4,420 KB
testcase_17 AC 12 ms
4,668 KB
testcase_18 AC 11 ms
4,380 KB
testcase_19 AC 10 ms
4,444 KB
testcase_20 AC 10 ms
4,376 KB
testcase_21 AC 10 ms
4,380 KB
testcase_22 AC 21 ms
6,688 KB
testcase_23 AC 34 ms
11,564 KB
testcase_24 AC 52 ms
16,624 KB
testcase_25 AC 28 ms
9,732 KB
testcase_26 AC 54 ms
17,180 KB
testcase_27 AC 51 ms
17,420 KB
testcase_28 AC 21 ms
6,492 KB
testcase_29 AC 19 ms
6,696 KB
testcase_30 AC 28 ms
9,268 KB
testcase_31 AC 48 ms
15,392 KB
testcase_32 AC 978 ms
304,688 KB
testcase_33 AC 586 ms
164,540 KB
testcase_34 MLE -
testcase_35 MLE -
testcase_36 AC 173 ms
22,840 KB
testcase_37 AC 911 ms
285,876 KB
testcase_38 AC 745 ms
232,704 KB
testcase_39 MLE -
testcase_40 AC 548 ms
141,044 KB
testcase_41 AC 911 ms
265,028 KB
testcase_42 MLE -
testcase_43 AC 1,038 ms
277,216 KB
testcase_44 MLE -
testcase_45 AC 461 ms
75,776 KB
testcase_46 MLE -
testcase_47 AC 708 ms
210,204 KB
testcase_48 MLE -
testcase_49 MLE -
testcase_50 AC 895 ms
284,076 KB
testcase_51 MLE -
testcase_52 TLE -
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 int 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<=2000;i++){
    for(j=0;buf%i==0;j++){
      buf/=i;
    }
    if(j>0)ret.emplace(i,j);
  }
  if(buf!=1)ret.emplace(buf,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<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(b[l[i]-1]!=b[r[i]])judge=true;
    if(judge)cout<<"Yes"<<endl;
    else cout<<"NO"<<endl;
  }
  
  return 0;
}
0