結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,384 KB
testcase_01 AC 8 ms
4,380 KB
testcase_02 AC 8 ms
4,380 KB
testcase_03 AC 8 ms
4,380 KB
testcase_04 AC 8 ms
4,384 KB
testcase_05 AC 8 ms
4,380 KB
testcase_06 AC 8 ms
4,380 KB
testcase_07 AC 8 ms
4,384 KB
testcase_08 AC 8 ms
4,384 KB
testcase_09 AC 8 ms
4,380 KB
testcase_10 AC 8 ms
4,384 KB
testcase_11 AC 8 ms
4,384 KB
testcase_12 AC 11 ms
4,628 KB
testcase_13 AC 11 ms
4,704 KB
testcase_14 AC 8 ms
4,380 KB
testcase_15 AC 9 ms
4,388 KB
testcase_16 AC 11 ms
4,528 KB
testcase_17 AC 12 ms
5,072 KB
testcase_18 AC 11 ms
4,384 KB
testcase_19 AC 10 ms
4,452 KB
testcase_20 AC 10 ms
4,384 KB
testcase_21 AC 11 ms
4,384 KB
testcase_22 AC 19 ms
6,584 KB
testcase_23 AC 32 ms
11,644 KB
testcase_24 AC 47 ms
17,036 KB
testcase_25 AC 27 ms
9,868 KB
testcase_26 AC 49 ms
17,296 KB
testcase_27 AC 49 ms
17,516 KB
testcase_28 AC 19 ms
6,504 KB
testcase_29 AC 17 ms
6,784 KB
testcase_30 AC 25 ms
9,452 KB
testcase_31 AC 45 ms
15,356 KB
testcase_32 AC 944 ms
304,896 KB
testcase_33 AC 541 ms
164,616 KB
testcase_34 MLE -
testcase_35 MLE -
testcase_36 AC 126 ms
22,848 KB
testcase_37 AC 894 ms
286,160 KB
testcase_38 AC 726 ms
232,784 KB
testcase_39 MLE -
testcase_40 AC 495 ms
141,124 KB
testcase_41 AC 871 ms
265,036 KB
testcase_42 MLE -
testcase_43 AC 951 ms
277,336 KB
testcase_44 MLE -
testcase_45 AC 353 ms
75,872 KB
testcase_46 MLE -
testcase_47 AC 684 ms
210,288 KB
testcase_48 MLE -
testcase_49 MLE -
testcase_50 AC 882 ms
284,464 KB
testcase_51 MLE -
testcase_52 AC 686 ms
173,948 KB
testcase_53 AC 587 ms
170,780 KB
testcase_54 AC 764 ms
205,480 KB
testcase_55 AC 563 ms
171,536 KB
testcase_56 AC 577 ms
180,152 KB
testcase_57 AC 498 ms
145,604 KB
testcase_58 AC 326 ms
60,824 KB
testcase_59 AC 418 ms
127,128 KB
testcase_60 AC 551 ms
145,896 KB
testcase_61 AC 140 ms
29,500 KB
testcase_62 AC 486 ms
123,012 KB
testcase_63 AC 493 ms
130,556 KB
testcase_64 AC 180 ms
51,304 KB
testcase_65 MLE -
testcase_66 AC 347 ms
92,896 KB
testcase_67 AC 812 ms
232,724 KB
testcase_68 AC 439 ms
100,204 KB
testcase_69 MLE -
testcase_70 AC 467 ms
142,924 KB
testcase_71 AC 520 ms
156,112 KB
testcase_72 AC 153 ms
24,052 KB
testcase_73 AC 914 ms
290,036 KB
testcase_74 MLE -
testcase_75 AC 543 ms
157,244 KB
testcase_76 AC 962 ms
276,248 KB
testcase_77 MLE -
testcase_78 AC 488 ms
111,868 KB
testcase_79 AC 868 ms
239,276 KB
testcase_80 AC 891 ms
253,324 KB
testcase_81 AC 899 ms
264,356 KB
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 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*i<=n&&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