PAT 甲级 1116. Come on! Let's C (20) 【循环判断】
题目链接
https://www.patest.cn/contests/pat-a-practise/1116
思路
注意一个细节
如果没有本来 ID 的 后来又查了这个ID 不是输出 checked 而是 Are you kidding?
AC代码
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits>
#define CLR(a) memset(a, 0, sizeof(a))
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const double PI = 3.14159265358979323846264338327;
const double E = exp(1);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;
bool isprime(int x)
{
int m = sqrt(x) + 1;
for (int i = 2; i <= m; i++)
{
if (x % i == 0)
return false;
}
return true;
}
int main()
{
int n, num;
map <int, int> m, flag;
cin >> n;
for (int i = 1; i <= n; i++)
{
scanf("%d", &num);
m[num] = i;
}
cin >> n;
for (int i = 0; i < n; i++)
{
scanf("%d", &num);
printf("%04d: ", num);
int vis = m[num];
if (vis == 0)
printf("Are you kidding?\n");
else if (flag[num] == 1)
printf("Checked\n");
else if (vis == 1)
printf("Mystery Award\n");
else if (isprime(vis))
printf("Minion\n");
else if (m[num])
printf("Chocolate\n");
flag[num] = 1;
}
}
PAT 甲级 1116. Come on! Let's C (20) 【循环判断】的更多相关文章
- PAT甲级:1124 Raffle for Weibo Followers (20分)
PAT甲级:1124 Raffle for Weibo Followers (20分) 题干 John got a full mark on PAT. He was so happy that he ...
- PAT 甲级 1023 Have Fun with Numbers(20)(思路分析)
1023 Have Fun with Numbers(20 分) Notice that the number 123456789 is a 9-digit number consisting exa ...
- pat 甲级 1065. A+B and C (64bit) (20)
1065. A+B and C (64bit) (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 HOU, Qiming G ...
- PAT 甲级 1065. A+B and C (64bit) (20) 【大数加法】
题目链接 https://www.patest.cn/contests/pat-a-practise/1065 思路 因为 a 和 b 都是 在 long long 范围内的 但是 a + b 可能会 ...
- PAT 甲级 1069 The Black Hole of Numbers (20 分)(内含别人string处理的精简代码)
1069 The Black Hole of Numbers (20 分) For any 4-digit integer except the ones with all the digits ...
- PAT 甲级 1065 A+B and C (64bit) (20 分)(溢出判断)*
1065 A+B and C (64bit) (20 分) Given three integers A, B and C in [−], you are supposed to tell whe ...
- PAT甲级——A1104 Sum of Number Segments【20】
Consider a positive integer N written in standard notation with k+1 digits ai as ak⋯a1a0 ...
- 【PAT甲级】1104 Sum of Number Segments (20 分)
题意:输入一个正整数N(<=1e5),接着输入N个小于等于1.0的正数,输出N个数中所有序列的和. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC ...
- 【PAT甲级】1058 A+B in Hogwarts (20 分)
题意: 输入两组,每组三个非负整数A,B,C(A<=1e7,B<17,C<29),输出相加的和.(类似个位上29进制,十位上17进制运算) AAAAAccepted code: #d ...
随机推荐
- mac 安装 redis
安装命令 brew install redis 开机启动redis命令 $ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents 使用 ...
- Mysql的时间戳转date类型
mysql 的 时间戳转date类型 select FROM_UNIXTIME(1491031706235/1000,'%Y-%m-%d') from dual;
- Win7无法启动,缺少系统文件ecache.sys怎么办
网上下载ecache.sys这个文件放到System32目录下即可 http://www.wenjian.net/file/ecache.sys.html
- android权限申请Permission
代码地址如下:http://www.demodashi.com/demo/12432.html android在6.0系统以后,权限申请变得麻烦起来,今天介绍一个超级好用的权限申请库,我在使用中经过再 ...
- Node.js学习笔记(4)——除了HTTP(服务器和客户端)部分
很多node入门的书里面都会在介绍node特性的时候说:单线程,异步式I/O,事件驱动. Node不是一门语言,它是运行在服务器端的开发平台,官方指定语言为javascript. 阻塞和线程: 线程在 ...
- ceres g2o 安装
.ceres 安装 Git clone https://github.com/ceres-solver/ceres-solver 安装依赖: # CMake sudo apt-get install ...
- 简单手机端头部设置 及css代码
<html> <head> <title>今日报表</title> <meta http-equiv="Content-Type&quo ...
- rtems 4.11 RTC驱动 (arm, beagle)
RTC驱动的框架在 c/src/lib/libbsp/shared/tod.c 中,大部分功能都已经实现了,入口函数是 rtc_initialize(),BSP要实现的东西非常少. beagle的实现 ...
- php通过curl下载远程图片实例
<?php $url = 'http://mf1905.com/upload/video_img/df3074c98ec5124ad47c52ff59f74e04_middle.jpeg'; f ...
- 1-3:CSS3课程入门之伪类和伪元素
E:target 表示当前的URL片段的元素类型,这个元素必须是E E:disabled 表示不可点击的表单控件 E:enabled 表示可点击的表单控件 E:checked 表示已选中的checkb ...