Codeforces 680C/679A Bear and Prime 100 solution

Solution in C++:

///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE,23rd batch

///Islamic University,Bangladesh  

#include<iostream>

using namespace std;

int main()

{


    int p[15] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};

    int i,c=0;

    for(i=0; i<15; i++)

    {

        cout<<p[i]<<endl;

        fflush(0);

        string s;

        cin>>s;

        if(s=="yes")

        {

            c++;

            if(p[i]*p[i]<=100)

            {

                cout<<p[i]*p[i]<<endl;

                fflush(0);

                cin>>s;

                if(s=="yes")

                    c++;

            }

        }

        if(c>1)

            break;

    }

    if(c>1)

        cout<<"composite"<<endl;

    else

        cout<<"prime"<<endl;

    fflush(0);


}


No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.