1116 Come on! Let's C
英文题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805355358306304
中文题目:https://pintia.cn/problem-sets/994805260223102976/problems/994805269828059136
1 #include<iostream> 2 #include<unordered_map> 3 using namespace std; 4 5 bool isPrime(int n) { 6 for(int i = 2; i*i <= n; ++i) 7 if(n%i == 0) return false; 8 return true; 9 } 10 int main() { 11 int n; 12 cin>>n; 13 unordered_map<string,int> mp; 14 unordered_map<string,bool> visited; 15 string str,hashtable[3] = {"Mystery Award","Minion","Chocolate"}; 16 for(int i = 1; i <= n; ++i) { 17 cin>>str; 18 if(i == 1) mp[str] = 0; 19 else if(isPrime(i)) mp[str] = 1; 20 else mp[str] = 2; 21 } 22 cin>>n; 23 while(n--) { 24 cin>>str; 25 printf("%s: ",str.c_str()); 26 if(mp.count(str) == 0) printf("Are you kidding?\n"); 27 else if(visited[str] == true) printf("Checked\n"); 28 else printf("%s\n",hashtable[mp[str]].c_str()),visited[str] = true; 29 } 30 return 0; 31 }


浙公网安备 33010602011771号