第一次交互题,记录一下吧

  1. #include <cstdio>
  2. #include <iostream>
  3. #include <ctime>
  4. #include <vector>
  5. #include <cmath>
  6. #include <map>
  7. #include <queue>
  8. #include <algorithm>
  9. #include <cstring>
  10. using namespace std;
  11. typedef long long LL;
  12. const int N=1e3+;
  13. const int INF=0x3f3f3f3f;
  14. const int mod=1e9+;
  15. int prime[];
  16. bool vis[];
  17. char s[];
  18. int main()
  19. {
  20. for(int i=;i<=;++i)
  21. if(!vis[i])
  22. for(int j=i*i;j<=;j+=i)
  23. vis[j]=;
  24. int cnt=;
  25. for(int i=;i<=;++i)
  26. if(!vis[i])prime[++cnt]=i;
  27. int ret=,x;
  28. for(int i=;i<=cnt;++i){
  29. printf("%d\n",prime[i]);
  30. fflush(stdout);
  31. scanf("%s",s);
  32. if(s[]=='y')++ret,x=prime[i];
  33. }
  34. if(ret>=){
  35. printf("composite\n");
  36. fflush(stdout);
  37. }
  38. else if(ret==){
  39. printf("2\n");
  40. fflush(stdout);
  41. scanf("%s",s);
  42. if(s[]=='y'){
  43. printf("composite\n");
  44. fflush(stdout);
  45. }
  46. bool flag=;
  47. for(int i=x*x;i<=;i*=x){
  48. printf("%d\n",i);
  49. fflush(stdout);
  50. scanf("%s",s);
  51. if(s[]=='y'){
  52. flag=;
  53. break;
  54. }
  55. }
  56. if(flag)printf("composite\n");
  57. else printf("prime\n");
  58. fflush(stdout);
  59. }
  60. else{
  61. int x=-;
  62. for(int i=;i<=;i*=){
  63. printf("%d\n",i);
  64. fflush(stdout);
  65. scanf("%s",s);
  66. if(s[]=='y'){
  67. x=i;
  68. }
  69. }
  70. if(x==-||x==)printf("prime\n");
  71. else printf("composite\n");
  72. fflush(stdout);
  73. }
  74. return ;
  75. }

codeforces 679A Bear and Prime 100 交互的更多相关文章

  1. Codeforces 679A Bear and Prime 100

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

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

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

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

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

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

  6. codeforces 356 div2 C.Bear and Prime 100 数学

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

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

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

  8. 680C. Bear and Prime 100 数学

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

  9. Codeforces 385C Bear and Prime Numbers

    题目链接:Codeforces 385C Bear and Prime Numbers 这题告诉我仅仅有询问没有更新通常是不用线段树的.或者说还有比线段树更简单的方法. 用一个sum数组记录前n项和, ...

随机推荐

  1. Android 使用系统的Activity播放音频文件 intent

    Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(Inten ...

  2. GitHub 开源工具整理

    技术站点 Hacker News:非常棒的针对编程的链接聚合网站 Programming reddit:同上 MSDN:微软相关的官方技术集中地,主要是文档类 infoq:企业级应用,关注软件开发领域 ...

  3. cojs 自己出的题目 解题报告

    省选成功成为河北B队队长QAQ 真是忧桑 所以在cojs上出了一套鬼畜的关于树的套题 黑白树: 我们先不考虑R操作 设x是u的祖先,那么fa(x)的贡献显然是 fa(x)*(sz(fa(x))-sz( ...

  4. 【Linux高频命令专题(23)】tar

    概述 通过SSH访问服务器,难免会要用到压缩,解压缩,打包,解包等,这时候tar命令就是是必不可少的一个功能强大的工具.linux中最流行的tar是麻雀虽小,五脏俱全,功能强大. tar命令可以为li ...

  5. CreateTwoArray

    public class CreateTwoArray{ public static void main(String []args){ int[][]arr=new int [2][3]; Syst ...

  6. 格林治时间,也就是返回从 UTC 1970 年 1 月 1 日午夜开始经过的毫秒数。

    格林治时间,也就是返回从 UTC 1970 年 1 月 1 日午夜开始经过的毫秒数. (* Delphi获取13位格林治时间实现方法, 与java中的java.lang.System.currentT ...

  7. C++:对象指针

    对象指针概念:每一个对象在初始化后都会在内存中占有一定的空间.因此,既可以通过对象名访问, 也可以通过一个对象地址来访问一个对象.对象指针就是用于存放对象地址的变量. 声明对象指针的一般语法格式为:类 ...

  8. 转:Servlet的url匹配以及url-pattern详解

    Servlet是J2EE开发中常用的技术,使用方便,配置简单,老少皆宜.估计大多数朋友都是直接配置用,也没有关心过具体的细节,今天遇到一个问题,上网查了servlet的规范才发现,servlet中的u ...

  9. mysql: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x90</...'

    插入数据出现问题,因为包含了特殊字符. 现象: 插入的数据中如果含有某些特殊字符,会导致插入数据失败,例如字符串”测试**插入数据...“,在console中insert是正常的,但是使用java代码 ...

  10. Zend Studio的配置和使用

    或许你可以用Dreamweaver.Notepad++或者Editplus这样的东西完成你的系统,但所谓“工欲善其事,必先利其器”,偶认为一个给力的IDE对于新手还是很必要的,而Zend作为PHPer ...