結果

問題 No.854 公平なりんご分配
ユーザー ChanyuhChanyuh
提出日時 2020-02-13 22:53:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,007 ms / 3,153 ms
コード長 2,655 bytes
コンパイル時間 1,072 ms
コンパイル使用メモリ 109,900 KB
実行使用メモリ 248,960 KB
最終ジャッジ日時 2024-04-15 23:29:47
合計ジャッジ時間 23,817 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,192 KB
testcase_01 AC 4 ms
8,132 KB
testcase_02 AC 5 ms
8,004 KB
testcase_03 AC 4 ms
8,192 KB
testcase_04 AC 5 ms
8,004 KB
testcase_05 AC 4 ms
8,080 KB
testcase_06 AC 5 ms
8,132 KB
testcase_07 AC 4 ms
8,064 KB
testcase_08 AC 5 ms
8,132 KB
testcase_09 AC 4 ms
8,192 KB
testcase_10 AC 5 ms
8,128 KB
testcase_11 AC 4 ms
8,192 KB
testcase_12 AC 5 ms
8,260 KB
testcase_13 AC 6 ms
8,212 KB
testcase_14 AC 5 ms
8,064 KB
testcase_15 AC 5 ms
8,136 KB
testcase_16 AC 6 ms
8,264 KB
testcase_17 AC 6 ms
8,260 KB
testcase_18 AC 6 ms
8,256 KB
testcase_19 AC 6 ms
8,192 KB
testcase_20 AC 6 ms
8,192 KB
testcase_21 AC 6 ms
8,320 KB
testcase_22 AC 9 ms
8,448 KB
testcase_23 AC 9 ms
9,216 KB
testcase_24 AC 14 ms
10,180 KB
testcase_25 AC 9 ms
8,904 KB
testcase_26 AC 14 ms
10,240 KB
testcase_27 AC 12 ms
10,308 KB
testcase_28 AC 9 ms
8,448 KB
testcase_29 AC 7 ms
8,448 KB
testcase_30 AC 9 ms
8,832 KB
testcase_31 AC 13 ms
9,796 KB
testcase_32 AC 135 ms
58,880 KB
testcase_33 AC 111 ms
35,144 KB
testcase_34 AC 225 ms
78,208 KB
testcase_35 AC 165 ms
63,232 KB
testcase_36 AC 62 ms
11,028 KB
testcase_37 AC 127 ms
55,748 KB
testcase_38 AC 103 ms
46,616 KB
testcase_39 AC 297 ms
82,560 KB
testcase_40 AC 117 ms
31,232 KB
testcase_41 AC 154 ms
52,096 KB
testcase_42 AC 215 ms
77,056 KB
testcase_43 AC 203 ms
54,216 KB
testcase_44 AC 234 ms
71,832 KB
testcase_45 AC 156 ms
20,160 KB
testcase_46 AC 274 ms
70,808 KB
testcase_47 AC 120 ms
42,820 KB
testcase_48 AC 201 ms
75,904 KB
testcase_49 AC 195 ms
77,440 KB
testcase_50 AC 122 ms
55,424 KB
testcase_51 AC 276 ms
74,112 KB
testcase_52 AC 197 ms
36,608 KB
testcase_53 AC 126 ms
36,168 KB
testcase_54 AC 201 ms
41,984 KB
testcase_55 AC 98 ms
36,352 KB
testcase_56 AC 89 ms
37,832 KB
testcase_57 AC 106 ms
32,000 KB
testcase_58 AC 148 ms
17,560 KB
testcase_59 AC 70 ms
28,928 KB
testcase_60 AC 137 ms
32,000 KB
testcase_61 AC 58 ms
12,228 KB
testcase_62 AC 140 ms
28,032 KB
testcase_63 AC 134 ms
29,252 KB
testcase_64 AC 46 ms
16,000 KB
testcase_65 AC 171 ms
68,352 KB
testcase_66 AC 94 ms
23,040 KB
testcase_67 AC 184 ms
46,592 KB
testcase_68 AC 156 ms
24,264 KB
testcase_69 AC 184 ms
82,632 KB
testcase_70 AC 84 ms
31,616 KB
testcase_71 AC 96 ms
33,792 KB
testcase_72 AC 84 ms
11,264 KB
testcase_73 AC 148 ms
56,388 KB
testcase_74 AC 243 ms
67,268 KB
testcase_75 AC 117 ms
33,808 KB
testcase_76 AC 204 ms
54,084 KB
testcase_77 AC 234 ms
75,540 KB
testcase_78 AC 172 ms
26,184 KB
testcase_79 AC 209 ms
47,680 KB
testcase_80 AC 199 ms
50,176 KB
testcase_81 AC 172 ms
52,036 KB
testcase_82 AC 887 ms
248,960 KB
testcase_83 AC 887 ms
248,900 KB
testcase_84 AC 892 ms
248,832 KB
testcase_85 AC 918 ms
248,832 KB
testcase_86 AC 778 ms
248,832 KB
testcase_87 AC 992 ms
248,896 KB
testcase_88 AC 984 ms
248,776 KB
testcase_89 AC 989 ms
248,832 KB
testcase_90 AC 1,007 ms
248,768 KB
testcase_91 AC 982 ms
248,832 KB
testcase_92 AC 986 ms
248,832 KB
testcase_93 AC 990 ms
248,832 KB
権限があれば一括ダウンロードができます

ソースコード

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]=10000;
        }
        return res;
    }
    rep(i,m){
        while(s%V[i]==0){
            res[i]++;
            s/=V[i];
        }
    }
    
    return res;
}

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

void solve(){
    cin >> n;
    vector<int> P=prime_list(0,2001);
    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,zero=true;
        rep(k,P.size()){
            T[k]=S[r][k]-S[l-1][k];
            if(T[k]<10000) zero=false;
            //cout << P[k] << " " << T[k] << " " << R[k] << endl;
            if(R[k]>T[k]){
                flag=false;
                break;
            }
        }
        if(zero) {cout << "Yes" << endl;continue;}
        if(p!=1) {cout << "NO" << endl;continue;}
        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