您的位置:首页 > 财经 > 金融 > 宁波网络推广的公司报价_页面设计高度_微信群二维码推广平台_aso是什么意思

宁波网络推广的公司报价_页面设计高度_微信群二维码推广平台_aso是什么意思

2024/12/21 22:51:19 来源:https://blog.csdn.net/2401_88085478/article/details/144613457  浏览:    关键词:宁波网络推广的公司报价_页面设计高度_微信群二维码推广平台_aso是什么意思
宁波网络推广的公司报价_页面设计高度_微信群二维码推广平台_aso是什么意思

"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?

题目大意: 给出n个学生的ID,他们的位置就是他们的排名。其中第一名会获得"Mystery Award",排名为素数的会获得“Minion”,其余排名都会获得“Chocolate”。之后k次查询,如果对应ID的学生出现过,且之前没有查询过,输出他对应的奖励;若之前查询过,输出Checked;若没有出现过,输出Are you kidding?

分析:用一个哈希表记录学生的名次,以及是否被查询过。之后每次查询对应输出即可。

#include<algorithm>
#include <iostream>
#include  <cstdlib>
#include  <cstring>
#include   <string>
#include   <vector>
#include   <cstdio>
#include    <queue>
#include    <stack>
#include    <ctime>
#include    <cmath>
#include      <map>
#include      <set>
#define INF 0xffffffff
#define db1(x) cout<<#x<<"="<<(x)<<endl
#define db2(x,y) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<endl
#define db3(x,y,z) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<", "<<#z<<"="<<(z)<<endl
#define db4(x,y,z,r) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<", "<<#z<<"="<<(z)<<", "<<#r<<"="<<(r)<<endl
#define db5(x,y,z,r,w) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<", "<<#z<<"="<<(z)<<", "<<#r<<"="<<(r)<<", "<<#w<<"="<<(w)<<endl
using namespace std;bool isprime(int a)
{for(int i=2;i*i<=a;++i)if(a%i==0)return 0;return 1;
}int main(void)
{#ifdef testfreopen("in.txt","r",stdin);//freopen("in.txt","w",stdout);clock_t start=clock();#endif //testint n;scanf("%d",&n);int num[10010]={0},flag[10010]={0};for(int i=1;i<=n;++i){int a;scanf("%d",&a);num[a]=i;}int k;scanf("%d",&k);for(int i=0;i<k;++i){int a;scanf("%d",&a);printf("%04d: ",a);if(flag[a]==1)printf("Checked\n");else if(num[a]==0)printf("Are you kidding?\n");else if(num[a]==1)flag[a]=1,printf("Mystery Award\n");else if(isprime(num[a]))flag[a]=1,printf("Minion\n");else flag[a]=1,printf("Chocolate\n");}#ifdef testclockid_t end=clock();double endtime=(double)(end-start)/CLOCKS_PER_SEC;printf("\n\n\n\n\n");cout<<"Total time:"<<endtime<<"s"<<endl;        //s为单位cout<<"Total time:"<<endtime*1000<<"ms"<<endl;    //ms为单位#endif //testreturn 0;
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com