Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя catismyfav

Автор catismyfav, история, 4 года назад, По-английски

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;

~~~~~

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор catismyfav, история, 4 года назад, По-английски

Hello all! I have started studying dfs and it's applications and I was studying topological sorting (https://www.spoj.com/problems/TOPOSORT/). I am stuck at the part to check the graph is Acyclic or not? Can anyone help with any easier way to check this? Thanks!

Полный текст и комментарии »

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

Автор catismyfav, история, 4 года назад, По-английски

Hello all! I was trying this problem. I understand the part that we have to count the numbers according to their modulo with 3 but I am stuck how to form DP states. Can someone please explain that. Thanks!

Полный текст и комментарии »

Теги #dp
  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится