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

题意:人机交互,回答是否整除,确定那个数;

思路:就是前14个素数,4个素数的平方

#include<bits/stdc++.h>
using namespace std;
#define ll __int64
#define mod 1000000007
#define pi (4*atan(1.0))
const int N=1e2+,M=1e6+,inf=1e9+;
int p[]={,,,,,,,,,,,,,,,,,,,,,,,,};
int aa[]={,,,};
char a[N][];
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int x,y=,n=,z,i,t=;
for(i=;i<;i++)
{
printf("%d\n",p[i]);
fflush(stdout);
scanf("%s",a[i]);
if(a[i][]=='y')
y++;
else
n++;
if(y>=)
break;
}
for(i=;i<;i++)
{
printf("%d\n",aa[i]);
fflush(stdout);
scanf("%s",a[i]);
if(a[i][]=='y')
y++;
else
n++;
if(y>=)
break;
}
if(y>=)
{
printf("composite\n");
fflush(stdout);
}
else
{
printf("prime\n");
fflush(stdout);
}
return ;
}

codeforces 356 div2 C.Bear and Prime 100 数学的更多相关文章

  1. 【CodeForces】679 A. Bear and Prime 100

    [题目]A. Bear and Prime 100 [题意]有一数字x,每次可询问一个数字y是否x的因子,最后输出数字x是否素数,要求询问次数<=20. [题解]容易发现[2,100]范围内的非 ...

  2. 680C. Bear and Prime 100 数学

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

  3. CF #356 div1 A. Bear and Prime 100

    题目链接:http://codeforces.com/contest/679/problem/A CF有史以来第一次出现交互式的题目,大致意思为选择2到100中某一个数字作为隐藏数,你可以询问最多20 ...

  4. 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 ...

  5. Codeforces Round #356 (Div. 2) C. Bear and Prime 100 水题

    C. Bear and Prime 100 题目连接: http://www.codeforces.com/contest/680/problem/C Description This is an i ...

  6. codeforces 680C C. Bear and Prime 100(数论)

    题目链接: C. Bear and Prime 100 time limit per test 1 second memory limit per test 256 megabytes input s ...

  7. Codeforces A - Bear and Prime 100(交互题)

    A - Bear and Prime 100 思路:任何一个合数都可以写成2个以上质数的乘积.在2-100中,除了4,9,25,49外都可以写成两个以上不同质数的乘积. 所以打一个质数加这四个数的表: ...

  8. 暑假练习赛 006 B Bear and Prime 100

    Bear and Prime 100Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:262144KB ...

  9. Codeforces 679A Bear and Prime 100

    链接:传送门 题意:给你一个隐藏数,这个隐藏数在[2,100]之间,现在最多可以询问20次,每次询问的是这个数是不是隐藏数的底数,是为yes,不是为no,每次询问后都需要flush一下输出缓冲区,最后 ...

随机推荐

  1. 监控linux流量python版

    python版监控linux流量 直接上代码,使用OptionParser来传入参数 #coding:utf-8 #------------- #Author:Hu #Data:20150520 #- ...

  2. angularJs初体验,实现双向数据绑定!使用体会:比较爽

    使用初体验:ng 双向数据绑定: 最简单的双向数据绑定:(使用默认模块控制) <body ng-app> <input type="text" ng-model= ...

  3. Python 中的map函数,filter函数,reduce函数

      自学python,很多地方都需要恶补.       三个函数比较类似,都是应用于序列的内置函数.常见的序列包括list.tuple.str.   1.map函数 map函数会根据提供的函数对指定序 ...

  4. 【php】---mysql语法增、删、改、查---【巷子】

    1.mysql基本语法 001.增 语法:          insert into 表名 (列1,列2,列3) values(值1,值2,值3)     批量插入:插入insert-插入多行   语 ...

  5. 170803、springboot jar包启动提示没有主清单属性

    问题:SpringBoot打包成jar后运行提示没有主清单属性 解决: 补全maven中的bulid信息 <plugin> <groupId>org.springframewo ...

  6. 《Git权威指南》读书笔记

    这本书一直在拿SVN和CVS 与Git进行对比.对于有过SVN和CVS经验的开发者来讲,这种方法很好,能够通过对比去了解各种的优缺点,从而更快地掌握Git的使用方法,更加欣赏Git.而对于刚刚接触源码 ...

  7. 利用阿里云腾讯云正版KMS服务器端口转发

    注意:以下内容仅供实验,请勿用于任何非法用途我们知道,阿里云和腾讯云在内网部署了KMS服务器,而且是正版的,那么,有没有办法使用公网的计算机直接或间接连接到这些KMS服务器呢,受代理服务器和跳板机配置 ...

  8. C# WinForm实现任务栏程序图标闪烁

    相信大家在用QQ的时候都会知道,你打开了QQ聊天窗口,如果窗口不是当前激活的窗口的话,收到QQ消息时,任务栏(不是托盘图标)上的图标会闪一下变成黄色(Win7默认主题下),用以通知用户有消息进来了,之 ...

  9. 自旋锁原理及java自旋锁

    一.自旋锁的概念 首先是一种锁,与互斥锁相似,基本作用是用于线程(进程)之间的同步.与普通锁不同的是,一个线程A在获得普通锁后,如果再有线程B试图获取锁,那么这个线程B将会挂起(阻塞):试想下,如果两 ...

  10. HTTP 请求头中的 X-Forwarded-For(转)

    原文:https://imququ.com/post/x-forwarded-for-header-in-http.html 我一直认为,对于从事 Web 前端开发的同学来说,HTTP 协议以及其他常 ...