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 ;
}

最新文章

  1. sdcms标签
  2. 用于基于 RPM 的 Linux 平台的 Java
  3. xbmc的静态链接办法
  4. 一些笔试题(C/C++)
  5. 如何生成DLL文件
  6. DCMTK3.6.0(MD支持库)安装说明
  7. Android中ScrollView嵌套GridView,解决GridView显示不全的问题
  8. Codeforces Round #365 (Div. 2) Mishka and trip
  9. 用Java实现向Cassandra数据库中插入和查询数据
  10. 核心概念 &mdash;&mdash; 服务容器
  11. hdoj 1035 Robot Motion
  12. SSM框架搭建web服务器实现登录功能(Spring+SpringMVC+Mybatis)
  13. service and intentservice
  14. Java并发编程--Fork/Join框架使用
  15. SpringMVC 学习-返回字符串中文乱码问题解决
  16. UVa 10405 &amp; POJ 1458 Longest Common Subsequence
  17. 201521123033《Java程序设计》第9周学习总结
  18. Crossin 8-3;8-4
  19. c++第0次作业
  20. &lt;转&gt;快速找到整数约数集方法&lt;python&gt;&lt;stackoverflow&gt;

热门文章

  1. WCF学习 (三)深入认识WCF契约
  2. shell脚本分析nginx日志
  3. ios8铃声
  4. EasyUI +MVC +EF实现增删改查
  5. MVC认识
  6. MySQL数据库连接池导致页面登录无法查询问题解决过程
  7. Spark-RDD算子
  8. Design Pattern in Simple Examples
  9. android(十四)四种启动模式
  10. python修改镜像源