当前位置:网站首页>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;
}
边栏推荐
- 三丁基-巯基膦烷「tBuBrettPhos Pd(allyl)」OTf),1798782-17-8
- 【Harmony OS】【FAQ】Hongmeng Questions Collection 1
- 阿里云对象存储oss私有桶生成链接
- MCM box model modeling method and source analysis of atmospheric O3
- 接口管理工具YApi怎么用?颜值高、易管理、超好用
- Unity2D horizontal board game tutorial 6 - enemy AI and attack animation
- 接口测试实战| GET/POST 请求区别详解
- 【HMS core】【Ads Kit】华为广告——海外应用在国内测试正式广告无法展示
- Windows 安装PostgreSQL
- 3. 无重复字符的最长子串
猜你喜欢
接口和协议
Interface Test Framework Practice | Process Encapsulation and Test Case Design Based on Encrypted Interface
荧光标记多肽FITC/AMC/FAM/Rhodamine/TAMRA/Cy3/Cy5/Cy7-Peptide
接口管理工具YApi怎么用?颜值高、易管理、超好用
私域流量时代来临,电商企业如何布局?
Modified BiotinDIAZO-Biotin-PEG3-DBCO|diazo-biotin-tripolyethylene glycol-diphenylcyclooctyne
【Harmony OS】【ARK UI】Date 基本操作
Kotlin-Flow common encapsulation class: the use of StateFlow
力扣561. 数组拆分
tag单调栈-单调栈预备知识-lt.739. 每日温度
随机推荐
在树莓派上搭建属于自己的网页(2)
Interface testing framework combat (3) | JSON request and response assertion
Interface test framework combat (1) | Requests and interface request construction
3. 无重复字符的最长子串
JS bottom handwriting
Flink state
接口管理工具YApi怎么用?颜值高、易管理、超好用
自组织是管理者和成员的双向奔赴
typescript45-接口之间的兼容性
【Harmony OS】【ARK UI】Date 基本操作
移动流量的爆发式增长,社交电商如何选择商业模式
荧光标记多肽FITC/AMC/FAM/Rhodamine/TAMRA/Cy3/Cy5/Cy7-Peptide
接口测试框架实战(四)| 搞定 Schema 断言
获取Ip工具类
表的创建、修改与删除
Build your own web page on raspberry pie (1)
typescript39-class类的可见修饰符
Power button 561. An array of split
【Harmony OS】【ARK UI】ets使用startAbility或startAbilityForResult方式调起Ability
User password encryption tool