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. Gallery 里面怎么设置ImageView的OnClick事件

    Gallery g=this.findViewById(R.id.gallery); g.setOnItemClickListener(new OnItemClickListener(){ @Over ...

  2. mongodb拆库分表脚本

    脚本功能: 1. 将指定的报告文件按照指定的字段.切库切表策略切分 2. 将切分后的文件并发导入到对应的Mongodb中 3. 生成日志文件和done标识文件 使用手册: -h    打印帮助信息,并 ...

  3. javascript飞机大战-----006创建敌机

    先写一个敌机类 /* 创建敌机: */ function Enemy(blood,speed,imgs){ //敌机left this.left = 0; //敌机top this.top = 0; ...

  4. AngularJs:Directive指令用法

    摘自:http://www.jb51.net/article/83051.htm 摘要:Directive(指令)是AngularJ非常强大而有有用的功能之一.它就相当于为我们写了公共的自定义DOM元 ...

  5. debug kibana in chrome

    kibana5.6.5版本 在kibana根目录运行命令:NODE_OPTIONS='--inspect --debug' npm start 也可以尝试命令:NODE_OPTIONS="- ...

  6. wsdl客户端代码生成的方法

    在jdk的bin目录下有一个wsimport.exe的工具,使用该工具命令生产java客户端代码: 命令如下: wsimport  -keep -d d:\ -s d:\src -p com.map  ...

  7. render的几个应用

    1.render可以通过模版语法来渲染字符串,例如变量,标签,for循环,这里就不赘述,我就举个自己印象很深刻灵活应用,看看render到底做了什么,关心什么 注意! 在rander眼里,没有html ...

  8. go-006-运算符

    运算符用于在程序运行时执行数学或逻辑运算. Go 语言内置的运算符有: 算术运算符 关系运算符 逻辑运算符 位运算符 赋值运算符 其他运算符 算术运算符 下表列出了所有Go语言的算术运算符.假定 A ...

  9. Spark的Java API例子详解

    package com.hand.study; import scala.Tuple2; import org.apache.spark.SparkConf; import org.apache.sp ...

  10. PAT 1111 Online Map[Dijkstra][dfs]

    1111 Online Map(30 分) Input our current position and a destination, an online map can recommend seve ...