結果

問題 No.854 公平なりんご分配
ユーザー daddydaddy
提出日時 2023-03-02 14:15:22
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 2,964 bytes
コンパイル時間 1,809 ms
コンパイル使用メモリ 182,752 KB
実行使用メモリ 814,644 KB
最終ジャッジ日時 2023-10-17 11:21:25
合計ジャッジ時間 99,818 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 12 ms
4,804 KB
testcase_23 AC 23 ms
7,736 KB
testcase_24 AC 59 ms
12,676 KB
testcase_25 AC 16 ms
6,572 KB
testcase_26 AC 57 ms
12,364 KB
testcase_27 AC 48 ms
12,540 KB
testcase_28 AC 10 ms
4,600 KB
testcase_29 AC 7 ms
4,796 KB
testcase_30 AC 16 ms
6,324 KB
testcase_31 AC 49 ms
10,708 KB
testcase_32 AC 1,546 ms
304,784 KB
testcase_33 AC 1,276 ms
164,072 KB
testcase_34 MLE -
testcase_35 MLE -
testcase_36 AC 435 ms
17,172 KB
testcase_37 AC 1,454 ms
286,304 KB
testcase_38 AC 1,150 ms
232,976 KB
testcase_39 TLE -
testcase_40 AC 1,348 ms
141,140 KB
testcase_41 AC 1,753 ms
264,920 KB
testcase_42 MLE -
testcase_43 AC 2,419 ms
277,064 KB
testcase_44 MLE -
testcase_45 AC 1,775 ms
72,904 KB
testcase_46 TLE -
testcase_47 AC 1,364 ms
210,272 KB
testcase_48 MLE -
testcase_49 MLE -
testcase_50 AC 1,402 ms
284,192 KB
testcase_51 TLE -
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 MLE -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 MLE -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 MLE -
testcase_75 WA -
testcase_76 WA -
testcase_77 MLE -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 MLE -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimization ("O3")

#include <bits/stdc++.h>

using namespace std;

using ll = int;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;
using dvec = vector<double>;
using dmat = vector<dvec>;

#define INF (1LL<<61)
#define MOD 1000000007LL 
//#define MOD 998244353LL

#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORE(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) {ASC((x)); REV((x));}
#define BIT(s,i) (((s)>>(i))&1)
#define pb push_back
#define fi first
#define se second

template<class T> inline int chmin(T& a, T b) {if(a>b) {a=b; return 1;} return 0;}
template<class T> inline int chmax(T& a, T b) {if(a<b) {a=b; return 1;} return 0;}

class mint {
public:
    ll x;
    mint(ll x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {return mint(-x);}
    mint& operator+=(const mint& a) {if((x+=a.x)>=MOD) x-=MOD; return *this;}
    mint& operator-=(const mint& a) {if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
    mint& operator*=(const mint& a) {(x*=a.x)%=MOD; return *this;}
    mint operator+(const mint& a) const {mint b(*this); return b+=a;}
    mint operator-(const mint& a) const {mint b(*this); return b-=a;}
    mint operator*(const mint& a) const {mint b(*this); return b*=a;}
    mint pow(ll t) const {if(!t) return 1; mint a=pow(t>>1); return (t&1?*this*a:a)*a;}
    mint inv() const {return pow(MOD-2);}
    mint& operator/=(const mint& a) {return *this*=a.inv();}
    mint operator/(const mint& a) const {mint b(*this); return b/=a;}
};
istream &operator>>(istream& is, mint& a) {ll t; is>>t; a=t; return is;}
ostream &operator<<(ostream& os, const mint& a) {return os<<a.x;}
using mvec = vector<mint>;
using mmat = vector<mvec>;

map<ll,ll> factorize(ll n)
{
    map<ll,ll> p;
    ll t = n;    
    for(ll i=2; i*i<=t; ++i) {
        ll cnt = 0;
        if(t%i) continue;
        while(t%i == 0) {
            t /= i;
            ++cnt;
        }
        p[i] = cnt;
    }
    if(t != 1) p[t] = 1;
    return p;
}

int main()
{
    ll N;
    cin >> N;

    vector<map<ll,ll>> C(N+1);
    set<ll> S;
    REP(i,1,N+1) {
        ll a;
        cin >> a;
        C[i] = factorize(a);
        FORE(p,C[i]) S.insert(p.fi);
    }
    REP(i,1,N+1) {
        FORE(p,S) C[i][p] += C[i-1][p];
    }

    ll Q;
    cin >> Q;
    while(Q--) {
        ll P, L, R;
        cin >> P >> L >> R;
        bool ans = true;
        map<ll,ll> F = factorize(P);
        FORE(p,F) {
            if(!S.count(p.fi)) ans = false;
        }
        if(ans) {
            FORE(p,S) {
                if(F[p] > C[R][p]-C[L-1][p]) {
                    ans = false;
                    break;
                }
            }
        }
        if(ans) PR("Yes");
        else PR("NO");
    }

    return 0;
}

/*



*/
0