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. 知道WCF的地址用工厂通道方式快速调用WCF

    知道WCF的地址用工厂通道方式快速调用WCF  1 using System;  2 using System.ServiceModel;  3 using System.ServiceModel.D ...

  2. Android动态添加布局

    //1.利用LayoutInflater的inflate动态加载XML mLinearLayout = (LinearLayout)findViewById(R.id.LinearLayout_ID) ...

  3. linux本机root账户无法登录,但是远程ssh可登录

    1.故障状态 a.linux本机root账户无法登录(root和密码无误的情况下也无法登录,但是用远程ssh软件可以登录) b.查看/var/log/secure登录日志(提示无法找到pam_limi ...

  4. 理解 php new static

    今天在看 Laravel 的容器(Container)实现时,发现了这么一段突然不能理解的代码: ** * Set the globally available instance of the con ...

  5. 浅谈vuex

    很多技术,刚接触的时候:这是啥?用的时候:哟嚯,是挺好用的!加以研究:卧槽,就是这么个逼玩意儿! 最近接手了一个别人写了1/5的vue项目(页面画了1/3,接口啥都没对); 对于表格中的数据项操作以及 ...

  6. MongoDB: 原子性和事务

    在MongoDB中, 文档级别的的写操作是原子性的, 甚至是在对某个文档的操作中修改其多个内嵌的子文档, 也是原子性的. 在一个写操作同时修改多个文档的情况, 对其中单独的某个文档而言是原子的, 但是 ...

  7. IOS #ifdef 的那些事儿

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/u012884714/article/details/25188685 格式有点乱,整了几次都整只是来 ...

  8. SLAM FOR DUMMIES 第5-8章 中文翻译

    5,SLAM的处理过程 SLAM过程包括许多步骤,该过程的目标是使用环境更新机器人的位置.由于机器人的里程计通常是存在误差的,我们不能直接依赖于里程计.我们可以用激光扫描环境来校正机器人的位置,这是通 ...

  9. spring boot security 登出

    <!DOCTYPE html> <html lang="zh-cn" xmlns:th="http://www.thymeleaf.org" ...

  10. lua关于参数生命周期的研究

    local num = 123 local str = "abc" local tb ={} 数字和字符串类型的值作为参数传递的时候,是复制值,2个独立的内存地址 table类型的 ...