当前位置:网站首页>PAT B1059
PAT B1059
2022-06-25 19:57:00 【Madness makes freedom】
1059 C Language contest (20 branch )
C The language contest is a happy contest hosted by the school of computer science of Zhejiang University . Since the theme of the competition is for fun , The award rules are funny :
- 0、 The champion will win a “ Mystery Award ”( For example, a huge collection of student research papers ……).
- 1、 Students who rank prime will win the best prize —— Little yellow doll !
- 2、 Others will get chocolate .
The final ranking of a given competition and the ranking of a series of contestants ID, You have to give the prizes that these contestants deserve .
Input format :
The first line of input gives a positive integer N(≤104), Is the number of contestants . And then N Row gives the final ranking , Each line gives a contestant's name in order of ranking ID(4 Digit composition ). Next, we give a positive integer K as well as K You need to query ID.
Output format :
For each query ID, Output in one line ID: Prize , One of the prizes or Mystery Award( Mystery Award )、 Or is it Minion( Minions )、 Or is it Chocolate( chocolate ). If the investigation ID It's not in the ranking at all , Print Are you kidding?( You're kidding me ?). If it's time to ID Already checked ( That is, the prize has been received ), Print ID: Checked( Don't eat too much ).
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?Put the contestant's ID Treat as a subscript !!!!
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
bool isPrimer(int n);
int main()
{
int n,a[10000]={0},id;
cin >> n;
for(int i=1;i<=n;++i)
{
cin >> id;
a[id]=i;
}
int k;
cin >> k;
int hashtable[10000]={0};
for(int i=1;i<=k;++i)
{
cin >> id;
if(a[id]==0)
printf("%04d: Are you kidding?\n",id);
else if(a[id]==1)
{
if(hashtable[id]==0)
{
printf("%04d: Mystery Award\n",id);
hashtable[id]=1;
}
else
printf("%04d: Checked\n",id);
}
else if(isPrimer(a[id]))
{
if(hashtable[id]==0)
{
printf("%04d: Minion\n",id);
hashtable[id]=1;
}
else
printf("%04d: Checked\n",id);
}
else
{
if(hashtable[id]==0)
{
printf("%04d: Chocolate\n",id);
hashtable[id]=1;
}
else
printf("%04d: Checked\n",id);
}
}
return 0;
}
bool isPrimer(int n)
{
int sqr=sqrt(n*1.0);
for(int i=2;i<=sqr;++i)
{
if(n%i==0)
return false;
}
return true;
}
边栏推荐
- Jump jump games auxiliary (manual version) py code implementation
- Thymleaf template configuration analysis
- Laravel validation rule followed Role of auth:: id()
- 一、HikariCP获取连接流程源码分析一
- Vulnhub range the planes:earth
- Is it safe for tongdaxin to open an account?
- The functions in the applet page are better than those in app JS first execution solution
- Solidity contract address to wallet, wallet address to contract
- PHP Chinese regular
- PHP database connection version1.1
猜你喜欢

Jsonp function encapsulation

Thymleaf template configuration analysis

Gbpnzd firm offer for 14 months, simulation for 19 months, test stable

The native JS mobile phone sends SMS cases. After clicking the button, the mobile phone number verification code is sent. The button needs to be disabled and re enabled after 60 seconds

Vulnhub range - the planes:venus

Arduino ide + esp8266+mqtt subscribe to publish temperature and humidity information

Server journey from scratch - Yu Zhongxian integrated version (IP access server, LNMP compilation and installation, Lua environment and socket expansion)

Vulnhub range - darkhole 1

Use of serialize() and serializearray() methods for form data serialization

Mail monitoring cloud script execution progress
随机推荐
Read multiple associations from a field using delimiters in laravel
Many varieties of EA can be used
Ali visual AI training camp -day05- creativity day - your image recognition project
2、 Hikaricp source code analysis of connection acquisition process II
Bindgetuserinfo will not pop up
Applet wx Request encapsulation
New features of php7
Applet canvas generate sharing Poster
Paddleocr learning (II) paddleocr detection model training
From now on, I will blog my code
Browser performance optimization (19)
Applet Click to return to the top 2 methods
Ali visual AI training camp -day03- construction of electronic photo album (face and expression recognition)
Mysql database design suggestions
rmi-registry-bind-deserialization
Tcp/ip test questions (I)
Verification code native JS canvas
Applet request interface encapsulation
Ali vision AI training camp-day01
Pat b1054 average (20 points)