当前位置:网站首页>1059 C语言竞赛 (20 分)(C语言)
1059 C语言竞赛 (20 分)(C语言)
2022-08-03 05:09:00 【破烂摆烂人】
C 语言竞赛是浙江大学计算机学院主持的一个欢乐的竞赛。既然竞赛主旨是为了好玩,颁奖规则也就制定得很滑稽:
0、冠军将赢得一份“神秘大奖”(比如很巨大的一本学生研究论文集……)。
1、排名为素数的学生将赢得最好的奖品 —— 小黄人玩偶!
2、其他人将得到巧克力。
给定比赛的最终排名以及一系列参赛者的 ID,你要给出这些参赛者应该获得的奖品。
输入格式:
输入第一行给出一个正整数 N(≤10
4
),是参赛者人数。随后 N 行给出最终排名,每行按排名顺序给出一位参赛者的 ID(4 位数字组成)。接下来给出一个正整数 K 以及 K 个需要查询的 ID。
输出格式:
对每个要查询的 ID,在一行中输出 ID: 奖品,其中奖品或者是 Mystery Award(神秘大奖)、或者是 Minion(小黄人)、或者是 Chocolate(巧克力)。如果所查 ID 根本不在排名里,打印 Are you kidding?(耍我呢?)。如果该 ID 已经查过了(即奖品已经领过了),打印 ID: Checked(不能多吃多占)。
输入样例:
6
1111
6666
8888
1234
5555
0001
6
8888
0001
1111
2222
8888
2222
输出样例:
8888: Minion
0001: Chocolate
1111: Mystery Award
2222: Are you kidding?
8888: Checked
2222: Are you kidding?
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int n , a[10000] ,flag[10000] = {
0} ,c[10000] = {
0} ;
scanf("%d",&n) ;
int i , j ;
for( i = 0 ; i < n ; i++ ){
scanf("%d",&a[i]) ;
}
int k , b[10000] ;
scanf("%d",&k) ;
for( i = 0 ; i < k ; i++ ){
scanf("%d",&b[i]) ;
}
flag[1] = 0 ;
for( i = 3 ; i <= n ; i++ ){
for( j = 2 ; j <= sqrt(i) ; j++ ){
if( i%j == 0 ){
flag[i-1] = 1 ;
}
}
}
for( i = 0 ; i < k ; i++ ){
for( j = 0 ; j < n ; j++ ){
if( b[i] == a[j] ){
if(c[j] == 0){
if( j == 0 ){
printf("%04d: Mystery Award\n",b[i]) ;
c[j] = 1 ;
}else if( flag[j] == 0 ){
printf("%04d: Minion\n",b[i]) ;
c[j] = 1 ;
}else{
printf("%04d: Chocolate\n",b[i]) ;
c[j] = 1 ;
}
break ;
}else{
printf("%04d: Checked\n",b[i]) ;
break ;
}
}
}
if( j == n ){
printf("%04d: Are you kidding?\n",b[i]) ;
}
}
return 0;
}
边栏推荐
- 自组织是管理者和成员的双向奔赴
- Installation of Apache DolphinScheduler version 2.0.5 distributed cluster
- js实现一个 bind 函数
- Interface Test Framework Practice | Process Encapsulation and Test Case Design Based on Encrypted Interface
- 数字化时代,企业如何建立自身的云平台与商业模式的选择?
- 【Biotin Azide|cas:908007-17-0】Price_Manufacturer
- 修饰生物素DIAZO-生物素-PEG3-DBCO|重氮-生物素-三聚乙二醇-二苯基环辛炔
- 3. 无重复字符的最长子串
- [Fine talk] Using native js to implement todolist
- Modified BiotinDIAZO-Biotin-PEG3-DBCO|diazo-biotin-tripolyethylene glycol-diphenylcyclooctyne
猜你喜欢
随机推荐
Flink状态
OSI的分层特点、传输过程与三次握手、四次挥手、tcp与udp包头的描述
idea使用@Autowired注解爆红原因及解决方法
【HMS core】【Ads Kit】华为广告——海外应用在国内测试正式广告无法展示
Common lipophilic cell membrane dyes DiO, Dil, DiR, Did spectrograms and experimental procedures
获取Ip工具类
unity2D横板游戏教程6-敌人AI以及受击动画
js garbage collection mechanism
业务表解析-余额系统
Super handy drawing tool is recommended
在线密码生成工具推荐
WebSocket的实际应用
【Biotin Azide|cas:908007-17-0】Price_Manufacturer
数字化时代,企业如何建立自身的云平台与商业模式的选择?
超好用的画图工具推荐
Harmony OS ets ArkUI 】 【 】 the development basic page layout and data connection
【Harmony OS】【ARK UI】Date 基本操作
Presto installation and deployment tutorial
【Harmony OS】【ARK UI】ets使用startAbility或startAbilityForResult方式调起Ability
【生物素叠氮化物|cas:908007-17-0】价格_厂家