!!!
查看原帖
!!!
872153
__TNT__楼主2023/12/5 14:37
#include <iostream>
#include <unordered_map>
#include <algorithm>

using namespace std;

const int N = 2e5 + 10;

int p[N];
int n, m;
unordered_map<int,int> mp;

int main()
{
    cin >> n >> m;
    for(int i = 0; i < n; i ++ )
    {
        int x;
        cin >> x;
        if(!mp.count(x)) mp[x] ++;
    }
    
    while(m -- )
    {
        int t;
        cin >> t;
        if(!p[t])
        {
            bool success = false;
            for(int j = 1; (long long)j * t < N; j ++ )
                if(mp.count((long long)j * t) && mp.count(j))
                {
                    success = true;
                    break;
                }
            if(success) p[t] = 1;
            else p[t] = 2;
        }
        
        if(p[t] == 1) puts("YES");
        else puts("NO");
    }
    return 0;
}

为啥有一个测试点过不去

2023/12/5 14:37
加载中...