結果

問題 No.854 公平なりんご分配
ユーザー ChanyuhChanyuh
提出日時 2020-02-13 22:39:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,592 bytes
コンパイル時間 2,332 ms
コンパイル使用メモリ 108,704 KB
実行使用メモリ 248,900 KB
最終ジャッジ日時 2024-04-15 23:28:00
合計ジャッジ時間 22,956 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
8,132 KB
testcase_01 AC 4 ms
8,136 KB
testcase_02 AC 4 ms
8,192 KB
testcase_03 AC 5 ms
8,064 KB
testcase_04 AC 4 ms
8,064 KB
testcase_05 AC 4 ms
8,064 KB
testcase_06 AC 4 ms
8,064 KB
testcase_07 AC 4 ms
8,192 KB
testcase_08 AC 4 ms
8,064 KB
testcase_09 AC 5 ms
8,064 KB
testcase_10 AC 4 ms
8,064 KB
testcase_11 AC 5 ms
8,064 KB
testcase_12 AC 5 ms
8,388 KB
testcase_13 AC 4 ms
8,192 KB
testcase_14 AC 4 ms
7,952 KB
testcase_15 AC 5 ms
8,192 KB
testcase_16 AC 4 ms
8,384 KB
testcase_17 AC 5 ms
8,388 KB
testcase_18 AC 4 ms
8,260 KB
testcase_19 AC 5 ms
8,212 KB
testcase_20 AC 5 ms
8,264 KB
testcase_21 AC 5 ms
8,260 KB
testcase_22 AC 7 ms
8,472 KB
testcase_23 AC 9 ms
9,156 KB
testcase_24 AC 12 ms
10,132 KB
testcase_25 AC 8 ms
9,028 KB
testcase_26 AC 12 ms
10,180 KB
testcase_27 AC 11 ms
10,180 KB
testcase_28 AC 8 ms
8,384 KB
testcase_29 AC 5 ms
8,468 KB
testcase_30 AC 8 ms
8,772 KB
testcase_31 AC 11 ms
9,924 KB
testcase_32 AC 139 ms
58,820 KB
testcase_33 AC 110 ms
35,140 KB
testcase_34 AC 225 ms
78,144 KB
testcase_35 AC 165 ms
63,124 KB
testcase_36 AC 60 ms
11,028 KB
testcase_37 AC 131 ms
55,620 KB
testcase_38 AC 103 ms
46,656 KB
testcase_39 AC 294 ms
82,500 KB
testcase_40 AC 113 ms
31,300 KB
testcase_41 AC 150 ms
52,036 KB
testcase_42 AC 208 ms
76,996 KB
testcase_43 AC 194 ms
54,212 KB
testcase_44 AC 231 ms
71,936 KB
testcase_45 AC 147 ms
20,036 KB
testcase_46 AC 263 ms
70,932 KB
testcase_47 AC 114 ms
42,880 KB
testcase_48 AC 198 ms
75,904 KB
testcase_49 AC 203 ms
77,512 KB
testcase_50 AC 127 ms
55,492 KB
testcase_51 AC 268 ms
74,180 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 AC 885 ms
248,832 KB
testcase_84 AC 892 ms
248,896 KB
testcase_85 AC 924 ms
248,776 KB
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 976 ms
248,900 KB
testcase_93 AC 989 ms
248,776 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]=-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,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(flag) cout << "Yes" << endl;
        else cout << "NO" << endl;
    }
}

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