zoukankan      html  css  js  c++  java
  • A1116 Come on! Let‘s C [map]

    在这里插入图片描述

    #include<iostream>
    #include<vector>
    #include<map>
    #include<string>
    #include<cstring>
    #include<cstdio>
    #include<algorithm>
    #include<cmath>
    using namespace std;
    const int maxn = 100001;
    int a[maxn];
    map<string, int>m;
    map<string, bool>e;
    bool isprime(int x)
    {
    	if (x <= 1)
    		return false;
    	for (int i = 2; i <= sqrt(x); i++)
    	{
    		if (x % i == 0)
    			return false;
    	}
    	return true;
    }
    int main()
    {
    	int n,q; string s;
    	cin >> n;
    	for (int i = 1; i <= n; i++)
    	{
    		cin >> s;
    		m[s] = i;
    		e[s] = true;
    	}
    	cin >> q;
    	for (int i = 1; i <= q; i++)
    	{
    		cin >> s;
    		auto j = m.find(s);
    		if (j!=m.end()&&m[s] == 1)
    		{
    			if (e[s])
    			{
    				cout << s << ":" << " " << "Mystery Award" << endl;
    				e[s] = false;
    			}
    			else
    				cout << s << ":" << " " << "Checked" << endl;
    		}
    		else if (j != m.end() && isprime(m[s]))
    		{
    			if (e[s])
    			{
    				cout << s << ":" << " " << "Minion" << endl;
    				e[s] = false;
    			}
    			else
    				cout << s << ":" << " " << "Checked" << endl;
    		}
    		else if(j != m.end())
    		{
    			if (e[s])
    			{
    				cout << s << ":" << " " << "Chocolate" << endl;
    				e[s] = false;
    			}
    			else
    				cout << s << ":" << " " << "Checked" << endl;
    		}
    		else
    		{
    			cout << s << ":" << " " << "Are you kidding?" << endl;
    		}
    	}
    }
    
  • 相关阅读:
    欢迎使用CSDN-markdown编辑器
    欢迎使用CSDN-markdown编辑器
    Math类简介
    Math类简介
    http_server
    tcp服务器
    swoole安装
    laravel源码解析
    VMware的Unity模式
    string.format() %d越界的问题
  • 原文地址:https://www.cnblogs.com/Hsiung123/p/13811974.html
Copyright © 2011-2022 走看看