-
Notifications
You must be signed in to change notification settings - Fork 1
/
1059. C语言竞赛(20)
66 lines (66 loc) · 1.19 KB
/
1059. C语言竞赛(20)
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
66
#include<stdio.h>
#include<math.h>
int isprime(int zqd);
int main(){
int N,M;
scanf("%d",&N);
int list[N];
for (int i = 0;i < N;i++){
scanf("%d",&list[i]);
}
scanf("%d",&M);
int kirby[M];
int cnt = 1;
for (int i = 0;i < M;i++){
scanf("%d",&kirby[i]);
int flag = 1;
for (int j = 0;j < i;j++){
if (kirby[i] == kirby[j]){
flag = 0;
break;
}
}
if (list[0] == kirby[i]){
if (cnt){
printf("%04d: Mystery Award\n",kirby[i]);
cnt = 0;
}else{
printf("%04d: Checked\n",kirby[i]);
continue;
}
}else{
for (int k = 1;k < N;k++){
if (list[k] == kirby[i]){
if (isprime(k + 1)&&flag){
printf("%04d: Minion\n",kirby[i]);
break;
}else if (flag){
printf("%04d: Chocolate\n",kirby[i]);
break;
}else{
printf("%04d: Checked\n",kirby[i]);
break;
}
}
if (k == N - 1){
printf("%04d: Are you kidding?\n",kirby[i]);
break;
}
}
}
}
return 0;
}
int isprime(int zqd){
if (zqd == 2||zqd == 3){
return 1;
}
int flag = 1;
for (int i = 2;i < sqrt(zqd) + 1;i++){
if (zqd % i == 0){
flag = 0;
break;
}
}
return flag;
}