Search
 
SCRIPT & CODE EXAMPLE
 

CPP

interactive problem

#include <cstdio>
#include <cstring>

using namespace std;

int main() {
    int l = 1, r = 1000000;
    while (l != r) {
        int mid = (l + r + 1) / 2;
        printf("%d
", mid);
        fflush(stdout);

        char response[3];
        scanf("%s", response);
        if (strcmp(response, "<") == 0)
            r = mid - 1;
        else
            l = mid;
    }

    printf("! %d
", l);
    fflush(stdout);
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: ex: java script 
Cpp :: Patrick and Shopping codeforces in c++ 
Cpp :: no argument but return value in c++ 
Cpp :: c++ how to iterate through 2d array in c++ 
Cpp :: c++ synchronization primitives example programs 
Cpp :: spyder enviroment 
Cpp :: how the theam are store in database 
Cpp :: c++ code 
Cpp :: initialize multiple variables to 0 c++ 
Cpp :: arduino jumper programmieren 
Cpp :: 10011101 
Cpp :: constructor init list 
Cpp :: how to define global array in c++ in a scope 
Cpp :: string class cpp 
Cpp :: csv 
Cpp :: is there anything like vector<intx[100] 
Cpp :: 2dvector c++ 
Cpp :: error when using template base class members 
Cpp :: hello command not printing in c++ 
Cpp :: char * in c++ 
Cpp :: c++ function parameters 
Cpp :: stack in c++ 
Cpp :: split string by delimiter cpp 
Cpp :: open a url with dev c 
Cpp :: memsert 
C :: how to create random integers from a specific range in c language 
C :: Animated sprite from few images pygame 
C :: reading string with spaces in c 
C :: c loop through binary search tree 
C :: reattach screen linux 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =