思路:如果该数是合数,那么他必定有两个及以上质因子组成,最小质因数是2,所以判断50内的素数就行了,至于2,3,5,7这四个还要特判他们的平方数。
# include <iostream>
# include <cstdio>
using namespace std;
int prime[]={2,3,4,5,7,9,11,13,17,19,23,25,29,31,37,41,43,47,49};
int main()
{
char s[10];
int p = 0;
for(int i=0; i<19; ++i)
{
printf("%d\n",prime[i]);
fflush(stdout);
scanf("%s",s);
if(s[0] == 'y') ++p;
}
if(p <= 1) puts("prime");
else puts("composite");
fflush(stdout);
return 0;
}