Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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);
}
Source by codeforces.com #
 
PREVIOUS NEXT
Tagged: #interactive #problem
ADD COMMENT
Topic
Name
3+7 =