codeforces 679A Bear and Prime 100 交互
第一次交互题,记录一下吧
- #include <cstdio>
- #include <iostream>
- #include <ctime>
- #include <vector>
- #include <cmath>
- #include <map>
- #include <queue>
- #include <algorithm>
- #include <cstring>
- using namespace std;
- typedef long long LL;
- const int N=1e3+;
- const int INF=0x3f3f3f3f;
- const int mod=1e9+;
- int prime[];
- bool vis[];
- char s[];
- int main()
- {
- for(int i=;i<=;++i)
- if(!vis[i])
- for(int j=i*i;j<=;j+=i)
- vis[j]=;
- int cnt=;
- for(int i=;i<=;++i)
- if(!vis[i])prime[++cnt]=i;
- int ret=,x;
- for(int i=;i<=cnt;++i){
- printf("%d\n",prime[i]);
- fflush(stdout);
- scanf("%s",s);
- if(s[]=='y')++ret,x=prime[i];
- }
- if(ret>=){
- printf("composite\n");
- fflush(stdout);
- }
- else if(ret==){
- printf("2\n");
- fflush(stdout);
- scanf("%s",s);
- if(s[]=='y'){
- printf("composite\n");
- fflush(stdout);
- }
- bool flag=;
- for(int i=x*x;i<=;i*=x){
- printf("%d\n",i);
- fflush(stdout);
- scanf("%s",s);
- if(s[]=='y'){
- flag=;
- break;
- }
- }
- if(flag)printf("composite\n");
- else printf("prime\n");
- fflush(stdout);
- }
- else{
- int x=-;
- for(int i=;i<=;i*=){
- printf("%d\n",i);
- fflush(stdout);
- scanf("%s",s);
- if(s[]=='y'){
- x=i;
- }
- }
- if(x==-||x==)printf("prime\n");
- else printf("composite\n");
- fflush(stdout);
- }
- return ;
- }
codeforces 679A Bear and Prime 100 交互的更多相关文章
- Codeforces 679A Bear and Prime 100
链接:传送门 题意:给你一个隐藏数,这个隐藏数在[2,100]之间,现在最多可以询问20次,每次询问的是这个数是不是隐藏数的底数,是为yes,不是为no,每次询问后都需要flush一下输出缓冲区,最后 ...
- Codeforces A - Bear and Prime 100(交互题)
A - Bear and Prime 100 思路:任何一个合数都可以写成2个以上质数的乘积.在2-100中,除了4,9,25,49外都可以写成两个以上不同质数的乘积. 所以打一个质数加这四个数的表: ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 【CodeForces】679 A. Bear and Prime 100
[题目]A. Bear and Prime 100 [题意]有一数字x,每次可询问一个数字y是否x的因子,最后输出数字x是否素数,要求询问次数<=20. [题解]容易发现[2,100]范围内的非 ...
- 680C. Bear and Prime 100 数学
C. Bear and Prime 100 time limit per test:1 second memory limit per test:256 megabytes input:standar ...
- Codeforces 385C Bear and Prime Numbers
题目链接:Codeforces 385C Bear and Prime Numbers 这题告诉我仅仅有询问没有更新通常是不用线段树的.或者说还有比线段树更简单的方法. 用一个sum数组记录前n项和, ...
随机推荐
- Android 使用系统的Activity播放音频文件 intent
Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(Inten ...
- GitHub 开源工具整理
技术站点 Hacker News:非常棒的针对编程的链接聚合网站 Programming reddit:同上 MSDN:微软相关的官方技术集中地,主要是文档类 infoq:企业级应用,关注软件开发领域 ...
- cojs 自己出的题目 解题报告
省选成功成为河北B队队长QAQ 真是忧桑 所以在cojs上出了一套鬼畜的关于树的套题 黑白树: 我们先不考虑R操作 设x是u的祖先,那么fa(x)的贡献显然是 fa(x)*(sz(fa(x))-sz( ...
- 【Linux高频命令专题(23)】tar
概述 通过SSH访问服务器,难免会要用到压缩,解压缩,打包,解包等,这时候tar命令就是是必不可少的一个功能强大的工具.linux中最流行的tar是麻雀虽小,五脏俱全,功能强大. tar命令可以为li ...
- CreateTwoArray
public class CreateTwoArray{ public static void main(String []args){ int[][]arr=new int [2][3]; Syst ...
- 格林治时间,也就是返回从 UTC 1970 年 1 月 1 日午夜开始经过的毫秒数。
格林治时间,也就是返回从 UTC 1970 年 1 月 1 日午夜开始经过的毫秒数. (* Delphi获取13位格林治时间实现方法, 与java中的java.lang.System.currentT ...
- C++:对象指针
对象指针概念:每一个对象在初始化后都会在内存中占有一定的空间.因此,既可以通过对象名访问, 也可以通过一个对象地址来访问一个对象.对象指针就是用于存放对象地址的变量. 声明对象指针的一般语法格式为:类 ...
- 转:Servlet的url匹配以及url-pattern详解
Servlet是J2EE开发中常用的技术,使用方便,配置简单,老少皆宜.估计大多数朋友都是直接配置用,也没有关心过具体的细节,今天遇到一个问题,上网查了servlet的规范才发现,servlet中的u ...
- mysql: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x90</...'
插入数据出现问题,因为包含了特殊字符. 现象: 插入的数据中如果含有某些特殊字符,会导致插入数据失败,例如字符串”测试**插入数据...“,在console中insert是正常的,但是使用java代码 ...
- Zend Studio的配置和使用
或许你可以用Dreamweaver.Notepad++或者Editplus这样的东西完成你的系统,但所谓“工欲善其事,必先利其器”,偶认为一个给力的IDE对于新手还是很必要的,而Zend作为PHPer ...