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 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.