感觉代码写的很对,但是只有65,求debug。
查看原帖
感觉代码写的很对,但是只有65,求debug。
687313
silky__player楼主2023/3/22 21:19
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int st[N], ans[N];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);


	int n, q;
	cin >> n >> q;
	vector<int>a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		st[a[i]]++;
	}
	for(int i = 0; i < n; i++){
		if(st[a[i]] >= 2) ans[1] = 1;
		if(a[i] == 1) continue;
		for(int j = 1; j * j <= a[i]; j++){
			if(a[i] % j == 0 && st[j]){
				ans[a[i] / j] = 1;
			}
		}
	}
	while (q--){
		int x;
		cin >> x;
		if (ans[x]) cout << "YES\n";
		else cout << "NO\n";
	}
	return 0;
}
2023/3/22 21:19
加载中...