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