'commit'
This commit is contained in:
30
TangDou/XiTi/1397.cpp
Normal file
30
TangDou/XiTi/1397.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
//输入+输出重定向
|
||||
//freopen("../x.in", "r", stdin);
|
||||
//freopen("../x.out", "w", stdout);
|
||||
int n;
|
||||
scanf("%d", &n);
|
||||
unordered_map<int, int> _map;
|
||||
for (int i = 1; i <= n; ++i) {
|
||||
int c;
|
||||
scanf("%d", &c);
|
||||
_map[c] = i; //key:个数,value:位置
|
||||
}
|
||||
int q;
|
||||
scanf("%d", &q);
|
||||
for (int i = 0; i < q; ++i) {
|
||||
int m;
|
||||
scanf("%d", &m);
|
||||
if (_map.count(m) > 0) printf("%d\n", _map[m]);
|
||||
else printf("%d\n", 0);
|
||||
}
|
||||
|
||||
//关闭文件
|
||||
//fclose(stdin);
|
||||
//fclose(stdout);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user