0
点赞
收藏
分享

微信扫一扫

stable diffusion webui 文生图(txt2img)api接口调用(使用C#)

题目描述

输入格式

输出格式

样例输入

5 3
4 2 3 3 1
2
4
6

样例输出

YES
YES
NO

提示

 解析:

        显然,忽略中间的齿轮,问题转换为这个是否存在两个数,他们的比为q。

       如果两层遍历找出所有的比值显然超时,所以可以寻找因数,然后记录比值即可。

代码:

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,q,a[N];
map<int,int>mp;
set<int>s;
int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		s.insert(a[i]);	
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		int t=a[i];
		for(int j=1;j*j<=t;j++){
			if(t%j==0){
				if(s.count(j)) mp[t/j]=1;
				if(s.count(t/j)) mp[j]=1;
			}
		}
	}
	while(q--){
		int t;
		scanf("%d",&t);
		if(mp.count(t)) puts("YES");
		else puts("NO");
	}
	return 0;
}
举报

相关推荐

0 条评论