結果

問題 No.854 公平なりんご分配
ユーザー ChanyuhChanyuh
提出日時 2020-02-13 22:42:28
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,555 bytes
コンパイル時間 2,024 ms
コンパイル使用メモリ 107,636 KB
実行使用メモリ 248,984 KB
最終ジャッジ日時 2024-04-15 23:28:28
合計ジャッジ時間 23,491 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,876 KB
testcase_01 AC 4 ms
8,128 KB
testcase_02 AC 4 ms
8,208 KB
testcase_03 AC 5 ms
8,132 KB
testcase_04 AC 5 ms
8,004 KB
testcase_05 AC 3 ms
8,132 KB
testcase_06 AC 4 ms
8,260 KB
testcase_07 AC 3 ms
8,084 KB
testcase_08 AC 5 ms
8,136 KB
testcase_09 AC 4 ms
8,260 KB
testcase_10 AC 4 ms
8,004 KB
testcase_11 AC 5 ms
8,132 KB
testcase_12 AC 5 ms
8,088 KB
testcase_13 AC 5 ms
8,216 KB
testcase_14 AC 4 ms
8,004 KB
testcase_15 AC 4 ms
8,000 KB
testcase_16 AC 4 ms
7,956 KB
testcase_17 AC 4 ms
8,260 KB
testcase_18 AC 4 ms
8,260 KB
testcase_19 AC 5 ms
8,260 KB
testcase_20 AC 4 ms
8,260 KB
testcase_21 AC 5 ms
8,260 KB
testcase_22 AC 7 ms
8,336 KB
testcase_23 AC 8 ms
9,156 KB
testcase_24 AC 11 ms
10,136 KB
testcase_25 AC 8 ms
8,900 KB
testcase_26 AC 13 ms
10,184 KB
testcase_27 AC 12 ms
10,312 KB
testcase_28 AC 7 ms
8,392 KB
testcase_29 AC 6 ms
8,340 KB
testcase_30 AC 7 ms
8,980 KB
testcase_31 AC 10 ms
9,928 KB
testcase_32 AC 135 ms
58,824 KB
testcase_33 AC 108 ms
35,144 KB
testcase_34 AC 220 ms
78,148 KB
testcase_35 AC 170 ms
63,300 KB
testcase_36 AC 60 ms
11,072 KB
testcase_37 AC 128 ms
55,616 KB
testcase_38 AC 100 ms
46,664 KB
testcase_39 AC 291 ms
82,500 KB
testcase_40 AC 114 ms
31,172 KB
testcase_41 AC 150 ms
52,036 KB
testcase_42 AC 215 ms
77,124 KB
testcase_43 AC 197 ms
54,168 KB
testcase_44 AC 236 ms
71,876 KB
testcase_45 AC 148 ms
20,160 KB
testcase_46 AC 265 ms
70,852 KB
testcase_47 AC 117 ms
42,900 KB
testcase_48 AC 204 ms
75,840 KB
testcase_49 AC 196 ms
77,332 KB
testcase_50 AC 124 ms
55,492 KB
testcase_51 AC 274 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 895 ms
248,772 KB
testcase_84 AC 884 ms
248,832 KB
testcase_85 AC 922 ms
248,776 KB
testcase_86 AC 777 ms
248,832 KB
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 948 ms
248,904 KB
testcase_93 AC 964 ms
248,896 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);
        if(p!=1) {cout << "NO" << endl;continue;}
        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