1116 Come on! Let‘s C

#include<iostream>

#include<iomanip>

#include<cmath>//处理根号

#include<set>

using namespace std;

int ran10001;

//判断是否为素数

bool isPrime(int a){

if(a<=1){

return false;

}

int sqrtNum=static_cast<int>(sqrt(a));

for(int i=2;i<=sqrtNum;i++){

if(a%i==0){

return false;

}

}

return true;

}

int main(){

int n,k;

cin>>n;

for(int i=0;i<n;i++){

int id;

cin>>id;

ranid=i+1;

}

cin>>k;

set<int>checked;

for(int i=0;i<k;i++){

int id;

cin>>id;

cout<<setw(4)<<setfill('0')<<id<<": ";

//检查id是否存在

if(ranid==0){

cout<<"Are you kidding?"<<endl;

continue;

}

//检查是否已经出现过

if(checked.find(id)!=checked.end()){

cout<<"Checked"<<endl;

continue;

}else{

checked.insert(id);

}

if(ranid==1){

cout<<"Mystery Award"<<endl;

}else if(isPrime(ranid)){

cout<<"Minion"<<endl;

}else{

cout<<"Chocolate"<<endl;

}

}

return 0;

}

相关推荐
木子算法12 分钟前
不是重心也不是中点:费马—韦伯点、它的最优性条件与迭代求解
人工智能·算法·目标跟踪
程序员AlbertTu41 分钟前
# Mantissa 使用教程 — Python 版与 C++ 版
c++·python·数值运算
Lazionr1 小时前
多态:从多种形态到运行时绑定
开发语言·c++
tryxr1 小时前
矩阵的几种基础变换
java·数据结构·算法·矩阵
mmmmath_31 小时前
LeetCode.028.找出字符串中第一个匹配项的
数据结构·算法·leetcode
别动我齐刘海1 小时前
ROS2 Jazzy + C++ 实战路线——ros2_control
c++·人工智能·python·opencv·机器学习·机器人·github
Selvaggia1 小时前
DMD(Distribution Matching Distillation,分布匹配蒸馏)
算法
Navigator_Z2 小时前
LeetCode //C - 1255. Maximum Score Words Formed by Letters
c语言·算法·leetcode
All for pursuit.2 小时前
【栈-4】739.每日温度
数据结构·c++·算法·leetcode
码匠许师傅2 小时前
【C++三方组件】glog:Google 出品的 C++ 日志库
c++