結果

問題 No.854 公平なりんご分配
ユーザー ChanyuhChanyuh
提出日時 2020-02-13 22:34:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,521 bytes
コンパイル時間 2,106 ms
コンパイル使用メモリ 106,256 KB
実行使用メモリ 813,664 KB
最終ジャッジ日時 2023-07-28 15:00:38
合計ジャッジ時間 14,693 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,048 KB
testcase_01 AC 5 ms
7,984 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 4 ms
8,040 KB
testcase_05 WA -
testcase_06 AC 4 ms
7,952 KB
testcase_07 WA -
testcase_08 AC 4 ms
8,208 KB
testcase_09 WA -
testcase_10 AC 4 ms
7,968 KB
testcase_11 AC 5 ms
8,068 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 4 ms
7,984 KB
testcase_15 AC 4 ms
8,228 KB
testcase_16 AC 5 ms
8,164 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 5 ms
8,052 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 AC 460 ms
244,528 KB
testcase_39 MLE -
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<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

vector<int> prime_list(int l,int r){//[l,r]に含まれる素数表
    vector<int> li(r+1,1);
    for(int i=2;i<=r;i++){
        if (!li[i]) continue;
        for(int j=2*i;j<=r;j+=i){
            li[j]=0;
        }
    }
    vector<int> res={};
    for(int i=max(2,l);i<=r;i++){
        if (li[i]) res.push_back(i);
    }
    return res;
}

vector<int> div(int s,vector<int> V){
    int m=V.size();
    vector<int> res(m,0);
    if(s==0){
        rep(i,m){
            res[i]=-1000;
        }
        return res;
    }
    rep(i,m){
        while(s%V[i]==0){
            res[i]++;
            s/=V[i];
        }
    }
    if(s!=1){
        rep(i,m){
            res[i]=1000;
        }
        return res;
    }
    return res;
}

int n,a[100010],q;
vector<int> A[100010],S[100010];

void solve(){
    cin >> n;
    vector<int> P=prime_list(0,n);
    S[0].resize(P.size(),0);
    rep(i,n){
        S[i+1].resize(P.size(),0);
        cin >> a[i];
        A[i]=div(a[i],P);
        rep(k,P.size()){
            S[i+1][k]=S[i][k]+A[i][k];
        }
    }
    cin >> q;
    rep(i,q){
        int p,l,r;cin >> p >> l >> r;
        vector<int> R=div(p,P);
        vector<int> T(P.size(),0);
        bool flag=true;
        rep(k,P.size()){
            T[k]=S[r][k]-S[l][k];
            if(R[k]>T[k]){
                flag=false;
                break;
            }
        }
        if(flag) cout << "Yes" << endl;
        else cout << "NO" << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}
0