文章

211

粉丝

1

获赞

1147

访问

40.4k

头像
动态查找问题 题解:
P1477
发布于2026年3月14日 14:34
阅读数 117

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,q,num;
	map<int,int> m;  //键,值
	cin>>n;
	while(n--){
		cin>>num;
		m[num]=1;
	}
	cin>>q;
	while(q--){
		cin>>num;
		if(m.count(num)) //count返回键出现的次数(0或1)
			cout<<"find"<<endl;
		else{
			cout<<"no"<<endl;
		 	m[num]=1;
		}
	}
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发