题意:
现在有一个属于[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;
}