Codeforces Round #356 (Div. 1)

题意:

现在有一个属于[2,100]的数,你有二十次询问系统的机会,每次询问一个[2,100]的数,并判断这个数是质数还是合数


题解:

搜100内的质数??首先,这些数有25个,然后,4,9,25,49这些数你是搜不出来的

如果是合数,其实搜50以内的质数就够,why?显然50*2 = 100,搜着些数能确保搜出这个合数的

最后,特判4,9,25,49,而11*11 = 121,再大也就不用特判了


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;

const int maxn = 110;
const int pri[30] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,4,9,25,49};

bool use[30];

int main()
{
	#ifdef YZY
		   freopen("yzy.txt","r",stdin);
	#endif
	
	int tot = 0;
	for (int i = 0; i < 19; i++) {
		printf("%d\n",pri[i]);
		fflush(stdout);
		char ch[5];
		cin >> ch;
		int len = strlen(ch);
		if (len == 3) {
			++tot;
			if (tot > 1) {
				printf("composite");
				fflush(stdout);
				return 0;
			}
		}
	}
	printf("prime"); 
	fflush(stdout);
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值