/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 540.0 KiB
#2 Wrong Answer 2ms 540.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
#define endl            '\n'
#define debug           cout<<"HERE"<<endl;
#define ff              first
#define ss              second
void edm()
{
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}
const int N = 1e5+5;
int cnt[N][20];
void solve()
{
    int n,k;cin>>n>>k;
    int arr[n+1];
    for(int i=1;i<=n;i++)cin>>arr[i];
    map<int,int>mp;
    int kk = k;
    vector<int>v;
    for(int i=2;i*i<=k;i++)
    {
        while(kk%i==0)
        {
            mp[i]++;
            kk = kk/i;
        }
    }
    if(kk!=1)mp[kk]++;
    for(auto i:mp)
    {
        v.pb(i.ff);
    }
    int koyta = mp.size();
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<v.size();j++)
        {
            while(arr[i]%v[j]==0)
            {
                cnt[i][j]++;
                arr[i] = arr[i]/v[j];
            }
        }
    }
    for(int j=0;j<koyta;j++)
    {
        for(int i=1;i<=n;i++)
        {
            cnt[i][j] = cnt[i-1][j] + cnt[i][j];
        }
    }
    int q;cin>>q;
    while(q--)
    {
        int a,b;cin>>a>>b;
        if(k==1)
        {
            cout<<"Yes"<<endl;
            continue;
        }
        int chk=1;
        for(int i=0;i<v.size();i++)
        {
            int koto = cnt[b][i] - cnt[a-1][i];
            auto it = mp.find(v[i]);
            if(it!=mp.end())
            {
               if(koto<mp[v[i]])
                {
                    chk=0;
                    break;
                } 
            }
        }
        if(chk)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<20;j++)
            {
                cnt[i][j]=0;
            }
        }
    }
}
int32_t main()
{
    //edm();
    int t = 1;
    cin >> t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
} 

Information

Submit By
Type
Submission
Problem
P1128 Roy and Product
Language
C++17 (G++ 13.2.0)
Submit At
2025-01-14 15:38:05
Judged At
2025-01-14 15:38:05
Judged By
Score
0
Total Time
2ms
Peak Memory
540.0 KiB