本文主要是介绍1059. C语言竞赛(20) PAT 乙级1116. Come on! Let's C (20) PAT甲级,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
甲级传送门
乙级传送门
坑点
一个不存在的ID查多次都是Are you kidding
#include<iostream>
#include<map>
#include<math.h>
using namespace std;int stu[10010];bool isPrime(int num){int m=sqrt(num);for(int i=2;i<=m;i++){if(num%i==0) return false;}return true;
}int main(){int N;int searchnum;int search;int num;//string s[3]={"","","",""};cin>>N;for(int i=1;i<=N;i++){cin>>num;stu[num]=i;}cin>>search;while(search--){cin>>searchnum;if(searchnum<10) cout<<"000";if(searchnum<100&&searchnum>=10) cout<<"00";if(searchnum<1000&&searchnum>=100) cout<<"0";if(stu[searchnum]==1){cout<<searchnum<<": Mystery Award"<<endl;stu[searchnum]=-1;continue;}if(stu[searchnum]==-1){cout<<searchnum<<": Checked"<<endl;stu[searchnum]=-1;continue;}if(stu[searchnum]==0){cout<<searchnum<<": Are you kidding?"<<endl;//stu[searchnum]=-1;continue;}if(isPrime(stu[searchnum])){cout<<searchnum<<": Minion"<<endl;stu[searchnum]=-1;continue;}cout<<searchnum<<": Chocolate"<<endl;stu[searchnum]=-1;}}
这篇关于1059. C语言竞赛(20) PAT 乙级1116. Come on! Let's C (20) PAT甲级的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!