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

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.