PAT 1116. 1116 Come on! Let's C (20 分)
原题链接
简单
作者:
大明湖的鱼
,
2021-03-21 10:22:15
,
所有人可见
,
阅读 263
无需二刷
#include <iostream>
#include<vector>
#include "set"
#include "map"
#include "string"
#include "algorithm"
using namespace std;
bool isPrime(int n){
for(int i = 2 ; i*i<=n;i++){
if(n%i ==0) return 0;
}
return 1;
}
int main(){
int n ;
cin>>n;
map<string,int> rank;
set<string> st;
map<string,int> visit;
for(int i = 1 ; i < n+1 ; i++){
string s;
cin>>s;
rank[s] = i;
st.insert(s);
}
int k ;
cin>>k;
for(int i = 0 ; i< k ;i++){
string s;
cin>>s;
cout<<s<<": ";
if(st.find(s) == st.end()) {
cout<<"Are you kidding?"<<endl;
// visit[s] = 1;
}
else if(visit[s] == 1){
cout<<"Checked"<<endl;
visit[s] = 1;
}
else if(rank[s] == 1) {
cout<<"Mystery Award"<<endl;
visit[s] = 1;
}
else if(isPrime(rank[s])) {
cout<<"Minion"<<endl;
visit[s] = 1;
}
else {
cout<<"Chocolate"<<endl;
visit[s] = 1;
}
}
}