結果

問題 No.854 公平なりんご分配
ユーザー ChanyuhChanyuh
提出日時 2020-02-13 22:49:41
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,612 bytes
コンパイル時間 1,319 ms
コンパイル使用メモリ 108,020 KB
実行使用メモリ 248,904 KB
最終ジャッジ日時 2024-10-06 06:38:10
合計ジャッジ時間 23,171 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
8,000 KB
testcase_01 AC 4 ms
8,004 KB
testcase_02 AC 4 ms
8,004 KB
testcase_03 AC 4 ms
8,132 KB
testcase_04 AC 3 ms
8,004 KB
testcase_05 AC 2 ms
8,128 KB
testcase_06 AC 3 ms
8,084 KB
testcase_07 AC 3 ms
8,088 KB
testcase_08 AC 4 ms
8,132 KB
testcase_09 AC 4 ms
8,132 KB
testcase_10 AC 4 ms
8,128 KB
testcase_11 AC 3 ms
8,084 KB
testcase_12 AC 3 ms
8,260 KB
testcase_13 AC 5 ms
8,256 KB
testcase_14 AC 4 ms
8,132 KB
testcase_15 AC 4 ms
8,132 KB
testcase_16 AC 4 ms
8,260 KB
testcase_17 AC 4 ms
8,260 KB
testcase_18 AC 4 ms
8,256 KB
testcase_19 AC 4 ms
8,388 KB
testcase_20 AC 4 ms
8,132 KB
testcase_21 AC 3 ms
8,212 KB
testcase_22 AC 6 ms
8,384 KB
testcase_23 AC 8 ms
9,236 KB
testcase_24 AC 12 ms
10,184 KB
testcase_25 AC 7 ms
8,852 KB
testcase_26 AC 12 ms
10,308 KB
testcase_27 AC 10 ms
10,132 KB
testcase_28 AC 6 ms
8,340 KB
testcase_29 AC 5 ms
8,388 KB
testcase_30 AC 6 ms
8,772 KB
testcase_31 AC 11 ms
9,800 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 58 ms
11,328 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 116 ms
31,128 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 154 ms
20,032 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 191 ms
36,624 KB
testcase_53 AC 135 ms
36,164 KB
testcase_54 AC 187 ms
42,180 KB
testcase_55 AC 101 ms
36,292 KB
testcase_56 AC 91 ms
37,700 KB
testcase_57 AC 102 ms
31,892 KB
testcase_58 AC 127 ms
17,428 KB
testcase_59 AC 70 ms
28,740 KB
testcase_60 AC 128 ms
32,020 KB
testcase_61 AC 52 ms
12,228 KB
testcase_62 AC 131 ms
27,968 KB
testcase_63 AC 126 ms
29,248 KB
testcase_64 AC 42 ms
15,940 KB
testcase_65 WA -
testcase_66 AC 84 ms
22,932 KB
testcase_67 AC 174 ms
46,532 KB
testcase_68 AC 137 ms
24,256 KB
testcase_69 AC 195 ms
82,624 KB
testcase_70 AC 82 ms
31,432 KB
testcase_71 AC 96 ms
33,600 KB
testcase_72 AC 81 ms
11,328 KB
testcase_73 AC 154 ms
56,264 KB
testcase_74 AC 231 ms
67,224 KB
testcase_75 AC 114 ms
33,860 KB
testcase_76 AC 196 ms
53,908 KB
testcase_77 AC 249 ms
75,460 KB
testcase_78 AC 154 ms
26,052 KB
testcase_79 AC 199 ms
47,684 KB
testcase_80 AC 195 ms
50,116 KB
testcase_81 AC 183 ms
51,904 KB
testcase_82 AC 927 ms
248,900 KB
testcase_83 AC 920 ms
248,904 KB
testcase_84 AC 910 ms
248,896 KB
testcase_85 AC 927 ms
248,772 KB
testcase_86 AC 840 ms
248,896 KB
testcase_87 AC 1,005 ms
248,772 KB
testcase_88 AC 1,006 ms
248,776 KB
testcase_89 AC 1,003 ms
248,772 KB
testcase_90 AC 1,020 ms
248,900 KB
testcase_91 AC 1,020 ms
248,900 KB
testcase_92 WA -
testcase_93 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
        rep(k,P.size()){
            T[k]=S[r][k]-S[l-1][k];
            //cout << P[k] << " " << T[k] << " " << R[k] << endl;
            if(R[k]>T[k]){
                flag=false;
                break;
            }
        }
        if(T[0]>=10000){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