PAT 1116

题目 : Come on! Let’s C

分值 : 20
难度 : 水题
思路 : 就普通的结构体操作
坑点 : %04d?

具体代码如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
using namespace std;
typedef struct Node{
int self ;
int rank ;
int flag = 0 ;
int exit = 0 ;
}Nodes ;
bool is_prime(int x)
{
if(x <2 )
return false ;
if(x ==2)
return true ;
for(int i = 2 ; i< x/2 ; i++)
if(x%i==0)
return false ;
return true ;
}
Nodes data[10001];
int main() {
int N ,K ;
cin >> N ;
for(int i = 0 ; i< N ; i++)
{
int temp ;
cin >> temp ;
data[temp].exit = 1 ;
data[temp].self = temp;
data[temp].rank = i +1 ;
}
cin >> K ;
for(int i = 0 ; i< K ; i++)
{
int temp ;
cin >> temp ;
if(!data[temp].exit)
{
printf("%04d: Are you kidding?\n",temp) ;
continue;
}
if(data[temp].flag)
{
printf("%04d: Checked\n",temp) ;
continue;
}
if(data[temp].rank == 1 )
{
printf("%04d: Mystery Award\n",temp) ;
data[temp].flag =1 ;
continue;
}
else if( is_prime( data[temp].rank) )
{
printf("%04d: Minion\n",temp) ;
data[temp].flag =1 ;
continue;
}
else {
printf("%04d: Chocolate\n",temp) ;
data[temp].flag = 1;
continue ;
}
}
}