Help with this interactive problem

Правка en1, от catismyfav, 2020-05-15 20:55:07

Hello! I was trying this problem Bear and Prime 100. I have used fflush(stdout) but it is showing idleness limit exceeded. Please help me with this. Here is the code and submission link ~~~~~

int square[] = {4,9,25,49};
int primes[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
int div=0;
for(int i=0;i<15;i++){
    cout<<primes[i]<<endl;
    fflush(stdout);
    string response;
    cin>>response;
    if(response[0]=='y') div++;
}
if(div>=2){
    cout<<"composite"<<endl; return ;
}
div=0;
for(int i=0;i<4;i++){
    cout<<square[i]<<endl;
    fflush(stdout);
    string response;
    cin>>response;
    if(response[0]=='y') div++;
}
if(div){
    cout<<"composite"<<endl; return;
}
cout<<"prime"<<endl;

~~~~~

Теги interactive

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский catismyfav 2020-05-15 20:55:07 985 Initial revision (published)