Codeforces 1. Guess the Number Solultion

Solution in C++:

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

///Islamic University,Bangladesh  

#include<iostream>

#include<string.h>

using namespace std;

int main()

{

    int l=1,r=1000000;

    while(l!=r)

    {

        int mid=(l+r+1)/2;

        printf("%d\n",mid);

        fflush(stdout);

        char ch[5];

        scanf("%s",&ch);

        if(strcmp(ch,"<")==0)

        {

            r=mid-1;

        }

        else

        {

           l=mid;

        }

    }

    printf("! %d\n", l);

    fflush(stdout);

}


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 ...

Powered by Blogger.