1116 Come on! Let's C (20 point(s))

本文介绍了一场由浙江大学计算机科学与技术学院举办的趣味编程比赛“Let's C”的奖品分配规则,包括神秘大奖、小黄人和巧克力。通过输入排名列表和参赛者ID序列,程序将输出对应奖品。

1116 Come on! Let's C (20 point(s))

"Let's C" is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun, the award rules are funny as the following:

  • 0、 The Champion will receive a "Mystery Award" (such as a BIG collection of students' research papers...).
  • 1、 Those who ranked as a prime number will receive the best award -- the Minions (小黄人)!
  • 2、 Everyone else will receive chocolates.

Given the final ranklist and a sequence of contestant ID's, you are supposed to tell the corresponding awards.

Input Specification:

Each input file contains one test case. For each case, the first line gives a positive integer N (≤10​4​​), the total number of contestants. Then N lines of the ranklist follow, each in order gives a contestant's ID (a 4-digit number). After the ranklist, there is a positive integer K followed by K query ID's.

Output Specification:

For each query, print in a line ID: award where the award is Mystery Award, or Minion, or Chocolate. If the ID is not in the ranklist, print Are you kidding? instead. If the ID has been checked before, print ID: Checked.

Sample Input:

6
1111
6666
8888
1234
5555
0001
6
8888
0001
1111
2222
8888
2222

Sample Output:

8888: Minion
0001: Chocolate
1111: Mystery Award
2222: Are you kidding?
8888: Checked
2222: Are you kidding?

简单题。

如果没有出现过的ID再次查询不输出Checked,题目没有说明,但可以从样例中看出来。

#include<stdio.h>
const int MAX = 1e4+7;
bool isChecked[MAX]={false};
int rank[MAX]={0};
bool isPrime(int n){
	for(int i=2;i*i<=n;i++){
		if(n%i==0) return false;
	}
	return true;
}
int main(void){
	int n,a;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a);
		rank[a]=i;
	}
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a);
		printf("%04d: ",a);
		if(rank[a]==0) printf("Are you kidding?\n");
		else if(isChecked[a]) printf("Checked\n");
		else{
			if(rank[a]==1) printf("Mystery Award\n");
			else if(isPrime(rank[a])) printf("Minion\n");
			else printf("Chocolate\n");
		}
		isChecked[a]=true;
	}
	return 0;
} 

 

c++题目,代码禁止有注释 A Angry Birds 作者 刘春英 单位 杭州电子科技大学 Aris is playing the classic game, Angry Birds! Because Aris has been playing for too long, Yuuka confiscated Aris’s game console and demanded that Aris complete today’s math homework before getting it back. However, Sensei did not assign any math homework to Aris today, so Yuuka had to come up with a problem for Aris to solve. Consider the game field of Angry Birds as a three-dimensional Euclidean space, and the bird as a sphere with radius R 3 ​ . Establish a spatial Cartesian coordinate system O−xyz, such that the trajectory of the bird’s center lies in the horizontal plane z=0. It is known that the trajectory of the bird’s center is a closed polyline, consisting of n segments connected end to end. The connection points are n points: (x 1 ​ ,y 1 ​ ,0),(x 2 ​ ,y 2 ​ ,0),⋯,(x n ​ ,y n ​ ,0). The i-th segment has endpoints (x i ​ ,y i ​ ,0) and (x imodn+1 ​ ,y imodn+1 ​ ,0). However, due to sensor errors, the actual n points may deviate from (x i ​ ,y i ​ ,0) by a distance not exceeding R 2 ​ (the sensor deviation R 2 ​ is the same for all points). That is, the actual i-th point (x i ′ ​ ,y i ′ ​ ,0) can be anywhere within the circle (which is still contained in the plane z=0) centered at (x i ​ ,y i ​ ,0) with radius R 2 ​ . Let S be the set of all points that the entire bird may pass through, i.e., points in 3D space whose distance to the bird’s center trajectory is at most R 3 ​ . Yuuka requires Aris to compute the volume of the convex hull of S. Convex hull: The convex hull of a point set S is defined as the smallest set T such that for any two points in S, all points on the line segment between them are contained in T. Input Format The first line contains a positive integer T (1≤T≤10 3 ), indicating the number of test cases. For each test case, the first line contains three integers n,R 2 ​ ,R 3 ​ (1≤n≤10 5 ,0≤R 2 ​ ,R 3 ​ ≤10 6 ), representing the number of connection points, the sensor error radius, and the bird radius, respectively. The next n lines each contain two integers x i ​ ,y i ​ (∣x i ​ ∣,∣y i ​ ∣≤10 6 ), representing the i-th connection point of the trajectory. It is guaranteed that the sum of n over all test cases in a single test point does not exceed 10 5 . Output Format For each test case, output a single floating-point number representing answer. Your answer is considered correct if the relative or absolute error compared to the standard answer is at most 10 −9 . Let your answer be a and the standard answer be b. If max{b,1} ∣a−b∣ ​ ≤10 −9 , it is considered correct. Sample 1 5 1 1 0 0 3 1 2 3 2 2 -1 3 77.622211120429587 Notes The convex hull of all points that the bird’s center may pass through: sample.png 代码长度限制 32 KB Java (javac) 时间限制 2000 ms 内存限制 256 MB Python (python2) 时间限制 2000 ms 内存限制 256 MB Python (python3) 时间限制 2000 ms 内存限制 256 MB Python (pypy3) 时间限制 2000 ms 内存限制 256 MB Kotlin (kotlinc) 时间限制 2000 ms 内存限制 256 MB 其他编译器 时间限制 1000 ms 内存限制 256 MB 栈限制 131072 KB
最新发布
10-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值