C. Bear and Prime 100
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

This is an interactive problem. In the output section below you will see the information about flushing the output.

Bear Limak thinks of some hidden number — an integer from interval [2, 100]. Your task is to say if the hidden number is prime or composite.

Integer x > 1 is called prime if it has exactly two distinct divisors, 1 and x. If integer x > 1 is not prime, it's called composite.

You can ask up to 20 queries about divisors of the hidden number. In each query you should print an integer from interval [2, 100]. The system will answer "yes" if your integer is a divisor of the hidden number. Otherwise, the answer will be "no".

For example, if the hidden number is 14 then the system will answer "yes" only if you print 2, 7 or 14.

When you are done asking queries, print "prime" or "composite" and terminate your program.

You will get the Wrong Answer verdict if you ask more than 20 queries, or if you print an integer not from the range [2, 100]. Also, you will get the Wrong Answer verdict if the printed answer isn't correct.

You will get the Idleness Limit Exceeded verdict if you don't print anything (but you should) or if you forget about flushing the output (more info below).

Input

After each query you should read one string from the input. It will be "yes" if the printed integer is a divisor of the hidden number, and "no" otherwise.

Output

Up to 20 times you can ask a query — print an integer from interval [2, 100] in one line. You have to both print the end-of-line character and flush the output. After flushing you should read a response from the input.

In any moment you can print the answer "prime" or "composite" (without the quotes). After that, flush the output and terminate your program.

To flush you can use (just after printing an integer and end-of-line):

  • fflush(stdout) in C++;
  • System.out.flush() in Java;
  • stdout.flush() in Python;
  • flush(output) in Pascal;
  • See the documentation for other languages.

Hacking. To hack someone, as the input you should print the hidden number — one integer from the interval [2, 100]. Of course, his/her solution won't be able to read the hidden number from the input.

Examples
Input
yes
no
yes
Output
2
80
5
composite
Input
no
yes
no
no
no
Output
58
59
78
78
2
prime
Note

The hidden number in the first query is 30. In a table below you can see a better form of the provided example of the communication process.

The hidden number is divisible by both 2 and 5. Thus, it must be composite. Note that it isn't necessary to know the exact value of the hidden number. In this test, the hidden number is 30.

59 is a divisor of the hidden number. In the interval [2, 100] there is only one number with this divisor. The hidden number must be 59, which is prime. Note that the answer is known even after the second query and you could print it then and terminate. Though, it isn't forbidden to ask unnecessary queries (unless you exceed the limit of 20 queries).

题意:

题解:

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<bits/stdc++.h>
#include<algorithm>
#include<queue>
#define ll __int64
using namespace std;
int aa[]={,,,};
int pr[]={,,,,,,,,,,,,,,,,,,,,,,,,};
char a[];
int x,y=;
int n=,z,i,t=;
int main()
{
for(i=;i<;i++)
{
printf("%d\n",pr[i]);
fflush(stdout);
scanf("%s",a);
if(strcmp(a,"yes")==)
y++;
else
n++;
if(y>=)
break;
}
for(i=;i<;i++)
{
printf("%d\n",aa[i]);
fflush(stdout);
scanf("%s",a);
if(strcmp(a,"yes")==)
y++;
else
n++;
if(y>=)
break;
}
if(y>=)
{
printf("composite\n");
fflush(stdout);
}
else
{
printf("prime\n");
fflush(stdout);
}
return ;
}

Codeforces Round #356 (Div. 2) C的更多相关文章

  1. Codeforces Round #356 (Div. 2)-B

    B. Bear and Finding Criminals 链接:http://codeforces.com/contest/680/problem/B There are n cities in B ...

  2. Codeforces Round #356 (Div. 2)-A

    A. Bear and Five Cards 题目链接:http://codeforces.com/contest/680/problem/A A little bear Limak plays a ...

  3. Codeforces Round #356 (Div. 2) C. Bear and Prime 100(转)

    C. Bear and Prime 100 time limit per test 1 second memory limit per test 256 megabytes input standar ...

  4. Codeforces Round #356 (Div. 2)B. Bear and Finding Criminals(水题)

    B. Bear and Finding Criminals time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  5. Codeforces Round #356 (Div. 2)A. Bear and Five Cards(简单模拟)

    A. Bear and Five Cards time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  6. 并查集+bfs+暴力滑窗 Codeforces Round #356 (Div. 2) E

    http://codeforces.com/contest/680/problem/E 题目大意:给你一个n*n的图,然后图上的 . (我们下面都叫做‘点’)表示可以走,X表示不能走,你有如下的操作, ...

  7. dfs Codeforces Round #356 (Div. 2) D

    http://codeforces.com/contest/680/problem/D 题目大意:给你一个大小为X的空间(X<=m),在该空间内,我们要尽量的放一个体积为a*a*a的立方体,且每 ...

  8. Codeforces Round #356 (Div. 1) D. Bear and Chase 暴力

    D. Bear and Chase 题目连接: http://codeforces.com/contest/679/problem/D Description Bearland has n citie ...

  9. Codeforces Round #356 (Div. 2) E. Bear and Square Grid 滑块

    E. Bear and Square Grid 题目连接: http://www.codeforces.com/contest/680/problem/E Description You have a ...

  10. Codeforces Round #356 (Div. 2) D. Bear and Tower of Cubes dfs

    D. Bear and Tower of Cubes 题目连接: http://www.codeforces.com/contest/680/problem/D Description Limak i ...

随机推荐

  1. LeetCode970. 强整数

    问题:970. 强整数 用户通过次数0 用户尝试次数0 通过次数0 提交次数0 题目难度Easy 给定两个非负整数 x 和 y,如果某一整数等于 x^i + y^j,其中整数 i >= 0 且  ...

  2. U盘装机记录

    U盘装机记录 1. 将U盘制作为启动盘(安装PE文件到U盘). (1)准备材料 8G以上U盘一个 一个可信的启动盘制作工具(这里是用的老毛桃) (2)将U盘插入电脑,单击老毛桃客户端(出现如下图所示的 ...

  3. 改进的平台设备驱动——dev和drv完全分离

    这是平台设备: 1 #include <linux/fs.h> #include <linux/init.h> #include <linux/delay.h> # ...

  4. 集合源码分析之 HashMap

    一 知识准备 HashMap是基于哈希表的Map接口的非同步实现.此实现提供所有可选的映射操作,并允许使用null值和null键.此类不保证映射的顺序,特别是它不保证该顺序恒久不变. 二  HashM ...

  5. 解决boostrap-table有水平和垂直滚动条时,滚动条滑到最右边表格标题和内容单元格无法对齐的问题

    问题:boostrap-table有水平和垂直滚动条时,滚动条不高的时候(滚动高度比较大的时候没有问题),滚动条滑到最右边表格标题和内容单元格无法对齐的问题 问题原因:bootstrap-table源 ...

  6. 算法学习记录-图——应用之关键路径(Critical Path)

    之前我们介绍过,在一个工程中我们关心两个问题: (1)工程是否顺利进行 (2)整个工程最短时间. 之前我们优先关心的是顶点(AOV),同样我们也可以优先关心边(同理有AOE).(Activity On ...

  7. Toolbar中menu菜单文字颜色的修改

    Toolbar菜单中menu当中我们大多数都使用图片来按钮,可是有些时候我们也会直接使用文字,文字的颜色如何修改呢. 其实很简单,我们只要修改styles.xml文件中,添加一句 <item n ...

  8. SpringBoot推荐基础包

    技术交流群:233513714 Spring Boot 推荐的基础包 名称 说明 spring-boot-starter 核心 POM,包含自动配置支持.日志库和对 YAML 配置文件的支持. spr ...

  9. Invalid bound statement (not found): com.up.sell.mapper.system.H5operationMapper.

    springboot + mybatis项目,出现这样的错误原因就是mapper类的名字和xml的id不对应或者是忘记写了,仔细检查一下吧

  10. 让菜鸡讲一讲网络流(isap)

    让我先讲一个故事吧. 一些小精灵要准备从银月城(S)迁徙到Nibel山(T). 这两个地方之间的道路构成了一个网络. 每个道路都有它自己的容量,这决定了每天有多少小精灵可以同时从这儿通过. 现在它们想 ...