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;

}

相关推荐
小郎君6582 小时前
Vue keep-alive 切标签后滚动位置回顶?因为 onDeactivated 里读到的 scrollTop 是 0
算法
CodeYp20192 小时前
第15讲:二叉搜索树
开发语言·c++·二叉搜索树
邵奈一2 小时前
GPT-6.1 Terra速度是Sol的3倍,价格减半
算法
RaaS1002 小时前
Node.js Brotli RCE 漏洞自查指南:fetch、undici、axios 都在影响面,三分钟确认你的版本
人工智能·深度学习·算法
shehuiyuelaiyuehao2 小时前
算法56,重排链表
数据结构·算法·链表
pipixia200333 小时前
C++继承面试四连问:内存叠加、私有继承、sizeof、权限重映射
c++·面试·嵌入式·继承·面向对象·对象模型
qq_452396233 小时前
第四篇:《索引原理与实战:B-tree、Hash、GIN、GiST、BRIN》
算法·哈希算法·gin
西索斯coding3 小时前
Qwen3-Max 与 Qwen-Plus:60 个真实修复任务评测方案
大数据·网络·算法·ai
INGNIGHT4 小时前
440 · 背包问题(三)(无限次数)
算法·leetcode·动态规划