题解 | #查找#
查找
https://www.nowcoder.com/practice/d93db01c2ee44e8a9237d63842aca8aa
#include <cstdio> #include<map> using namespace std; int main() { map<int,int> index; int n; int arr[100]; while(scanf("%d",&n)!=EOF){ for(int i=0;i<n;++i){ scanf("%d",&arr[i]); index[arr[i]]=i; } int m; scanf("%d",&m); for(int i=0;i<m;++i){ int b; scanf("%d",&b); if(index.find(b)==index.end()){ printf("NO\n"); } else{ printf("YES\n"); } } } return 0; } // 64 位输出请用 printf("%lld")