/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 2ms 592.0 KiB
#3 Accepted 49ms 864.0 KiB
#4 Accepted 52ms 844.0 KiB
#5 Accepted 49ms 1.27 MiB
#6 Accepted 72ms 1.098 MiB
#7 Accepted 58ms 3.688 MiB
#8 Accepted 123ms 4.43 MiB
#9 Accepted 66ms 3.719 MiB
#10 Accepted 82ms 24.469 MiB
#11 Accepted 50ms 12.32 MiB
#12 Accepted 73ms 18.473 MiB
#13 Accepted 59ms 4.848 MiB
#14 Accepted 68ms 4.207 MiB
#15 Accepted 103ms 1.027 MiB
#16 Accepted 105ms 876.0 KiB
#17 Accepted 44ms 892.0 KiB
#18 Accepted 105ms 900.0 KiB
#19 Accepted 61ms 1.109 MiB
#20 Accepted 67ms 4.172 MiB
#21 Accepted 130ms 36.609 MiB
#22 Accepted 126ms 36.688 MiB
#23 Accepted 106ms 12.285 MiB
#24 Accepted 227ms 61.211 MiB
#25 Accepted 54ms 12.359 MiB
#26 Accepted 334ms 960.0 KiB
#27 Accepted 102ms 12.766 MiB

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

void solve()
{
    ll n,x,val,q,l,r;
    cin>>n>>x;
    val=x;
    vector <ll> v(n+1);
    for(int i=1;i<=n;i++) cin>>v[i];

    map <ll,ll> mp;
    for(int i=2;i*i<=x;i++){
        if(x%i==0){
            while(x%i==0){
                mp[i]++;
                x/=i;
            }
        }
    }
    if(x>1) mp[x]++;
    vector <map<ll,ll>> vmp(n+1);
    
    for(auto it:mp){
        for(int i=1;i<=n;i++){
            ll cnt=0;
            while(v[i]%it.first==0){
                cnt++;
                v[i]/=it.first;
            }
            vmp[i][it.first]=vmp[i-1][it.first]+cnt;
        }
    }
    cin>>q;
    while(q--){
        cin>>l>>r;
        ll possible=0;

        for(auto it:mp){
            ll have=(vmp[r][it.first]-vmp[l-1][it.first]);
            if(have<it.second){
                possible=1;
                break;
            }
        }

        if(possible){
            cout<<"No\n";
        }
        else cout<<"Yes\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t=1;cin>>t;
    while(t--){
        solve();
    }
}

Information

Submit By
Type
Submission
Problem
P1128 Roy and Product
Language
C++17 (G++ 13.2.0)
Submit At
2025-01-16 16:54:20
Judged At
2025-01-16 16:54:20
Judged By
Score
100
Total Time
334ms
Peak Memory
61.211 MiB