PAT乙级 C语言竞赛

#include 
#include 
#include 
#include 

using namespace std;
bool primeNumber(int a){
    int i,k;
    k=(int)sqrt(a);
    for(i=2;i<=k;i++){
        if(a%i==0){
            break;
        }
    }
    return i>k;
}

int main(){
    int N,num,K;
    int rank[10001]={0};
    vector<int> queryNum;
    set<int> querySet;
    cin>>N;
    for(int i=0;icin>>num;
        rank[num]=i+1;
    }
    cin>>K;
    for(int i=0;icin>>num;
        queryNum.push_back(num);
    }
    for(int i=0;iif(rank[num]==0){
            printf("%04d: Are you kidding?\n",num);
        }else if(querySet.count(num)==1){
            printf("%04d: Checked\n",num);
        }else if(querySet.count(num)==0){
            querySet.insert(num);
            if(rank[num]==1){
                printf("%04d: Mystery Award\n",num);
            }else if(primeNumber(rank[num])){
                printf("%04d: Minion\n",num);
            }else{
                printf("%04d: Chocolate\n",num);
            }
        }
    }
    return 0;
}

你可能感兴趣的:(c++,PAT)