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
  1. yes
    no
    yes
output
  1. 2
    80
    5
    composite
input
  1. no
    yes
    no
    no
    no
output
  1. 58
    59
    78
    78
    2
    prime

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

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

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll __int64
  4. #define mod 1000000007
  5. #define pi (4*atan(1.0))
  6. const int N=1e2+,M=1e6+,inf=1e9+;
  7. int p[]={,,,,,,,,,,,,,,,,,,,,,,,,};
  8. int aa[]={,,,};
  9. char a[N][];
  10. int main()
  11. {
  12. //freopen("input.txt", "r", stdin);
  13. //freopen("output.txt", "w", stdout);
  14. int x,y=,n=,z,i,t=;
  15. for(i=;i<;i++)
  16. {
  17. printf("%d\n",p[i]);
  18. fflush(stdout);
  19. scanf("%s",a[i]);
  20. if(a[i][]=='y')
  21. y++;
  22. else
  23. n++;
  24. if(y>=)
  25. break;
  26. }
  27. for(i=;i<;i++)
  28. {
  29. printf("%d\n",aa[i]);
  30. fflush(stdout);
  31. scanf("%s",a[i]);
  32. if(a[i][]=='y')
  33. y++;
  34. else
  35. n++;
  36. if(y>=)
  37. break;
  38. }
  39. if(y>=)
  40. {
  41. printf("composite\n");
  42. fflush(stdout);
  43. }
  44. else
  45. {
  46. printf("prime\n");
  47. fflush(stdout);
  48. }
  49. return ;
  50. }

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. 第k最短路A*启发式搜索

    Remmarguts' Date Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 21549   Accepted: 5862 ...

  2. reflect 机制

    1: Class.forName的作用?为什么要用? 答:调用该访问返回一个以字符串指定类名的类的对象. 2: 通过反射,有几种方法可以实例化Class类对象? 3种,第一种:Class.forNam ...

  3. centos7修改网卡名、密码重置

    修改网卡名称 编辑 /etc/sysconfig/grub   倒数第二行quiet 后加入 net.ifnames=0  biosdevname=0 执行 grub2-mkconfig -o /bo ...

  4. pandas读取保存数据

    将本人使用过的一些操作记录下来 1.读取数据,使用:data = pd.read_csv('./data/file.csv') 2.数据处理,如果你要修改某一个数据,其实把DATAFRAME数据看做是 ...

  5. 关于java web的笔记2018-01-12

    需求:1.写一个商品类,有商品编号.商品名称.商品分类.商品单价属性.2.写一个商品条目信息类,有商品和数量两个属性,有商品总价格方法.3.写一个购物车类,有添加商品方法.查看订单信息,删除商品,修改 ...

  6. XPipe 解决什么问题

    x-pipe/README.md at master · ctripcorp/x-pipe https://github.com/ctripcorp/x-pipe/blob/master/README ...

  7. mysql线上负载高怎么排查

    作为一个开发人员或者数据库管理员,学会检查数据库运行情况是必不可少的工作.造成MySQL线程卡顿的原因有很多,但是无论是哪种原因,我们发现问题之后的第一要务就是解决问题,防止问题继续恶化.那么,应该如 ...

  8. DNS中A记录和CNAME记录的区别(转)

    A记录是域名到ip的映射,即为ip起别名:CNAME是域名别名到域名的映射,即为域名起别名. 还有一个常用的记录是MX记录,它是与邮件相关的,MX记录记录了发送电子邮件时域名对应的服务器地址. 原文: ...

  9. 两个提高工作效率的神器-Restlet Client和fe助手

    首先是要FQ,百度***或者直接下载蓝灯. 然后安装第一个WEB前端助手:

  10. [C#]解决程序Vista/Win7下因UAC导致的读写错误

    在微软的操作系统中,vista和win7加入了UAC的功能,UAC(User Account Control,用户帐户控制)是微软为提高系统安全而在Windows Vista中引入的新技术,它要求用户 ...