cf 680 c
2016-06-09 16:23
393 查看
链接:http://codeforces.com/contest/680/problem/C
题意:给你一个数字,让你查询不超过20次判断是素数还是合数
//判断2 -100 以内是素数还是合数 由于最多查询20次 我们可以查询20次来判断是否是素数,小于100的合数一定有因子是2,3,5,7 有可能是素数因子就是本身,所以要增加4,9,25,49,来判断是否是合数
#include <bits/stdc++.h>
using namespace std;
int a[20]={2,3,4,5,7,9,11,13,17,19,23,25,29,31,37,41,43,47,49,53};
map<int,int>m;
int main()
{
string s;
int cnt=0;
for(int i=0;i<20;i++)
{
printf("%d\n",a[i]);
fflush(stdout);
cin>>s;
if(s=="yes")
{
cnt++;
m[a[i]]++;
}
}
if(cnt<2)
printf("prime\n");
else
printf("composite\n");
return 0;
}
题意:给你一个数字,让你查询不超过20次判断是素数还是合数
//判断2 -100 以内是素数还是合数 由于最多查询20次 我们可以查询20次来判断是否是素数,小于100的合数一定有因子是2,3,5,7 有可能是素数因子就是本身,所以要增加4,9,25,49,来判断是否是合数
#include <bits/stdc++.h>
using namespace std;
int a[20]={2,3,4,5,7,9,11,13,17,19,23,25,29,31,37,41,43,47,49,53};
map<int,int>m;
int main()
{
string s;
int cnt=0;
for(int i=0;i<20;i++)
{
printf("%d\n",a[i]);
fflush(stdout);
cin>>s;
if(s=="yes")
{
cnt++;
m[a[i]]++;
}
}
if(cnt<2)
printf("prime\n");
else
printf("composite\n");
return 0;
}
相关文章推荐
- property和constructor-arg设值注入
- 20135327--实践三
- CPU寄存器
- 构造方法
- Java NIO
- Codeforces-Round-#356-(Div.-2)-Bear-and-Finding-Criminals
- python的GUI编程--wxpython学习(二)--基本控件和事件
- random forest
- c语言 程序 快速排序
- IO流-Properties
- 递归
- 《用tcp/ip进行网际互联》第6章 网际协议:无连接数据报交付
- hdu 最短路径
- sqlplus执行SQL文件
- Compare Version Numbers
- atom无法安装插件的解决方法之一
- SSH开发问题——attempt to create saveOrUpdate event with null entity
- Dns & IPAddress
- SQL 2008 视频总结(三)
- LeetCode-37.Sudoku Solver