結果

問題 No.246 質問と回答
ユーザー はむ吉🐹はむ吉🐹
提出日時 2015-12-28 20:22:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 10,724 KB
実行使用メモリ 24,360 KB
平均クエリ数 31.23
最終ジャッジ日時 2023-09-23 20:10:21
合計ジャッジ時間 3,577 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
24,348 KB
testcase_01 AC 52 ms
23,916 KB
testcase_02 AC 52 ms
23,308 KB
testcase_03 AC 55 ms
24,204 KB
testcase_04 AC 53 ms
24,336 KB
testcase_05 AC 55 ms
24,204 KB
testcase_06 AC 53 ms
23,580 KB
testcase_07 AC 53 ms
24,360 KB
testcase_08 AC 53 ms
23,476 KB
testcase_09 AC 54 ms
23,448 KB
testcase_10 AC 53 ms
23,724 KB
testcase_11 AC 53 ms
24,156 KB
testcase_12 AC 54 ms
23,964 KB
testcase_13 AC 53 ms
24,084 KB
testcase_14 AC 53 ms
23,672 KB
testcase_15 AC 52 ms
23,652 KB
testcase_16 AC 53 ms
23,764 KB
testcase_17 AC 51 ms
24,168 KB
testcase_18 AC 51 ms
23,672 KB
testcase_19 AC 51 ms
24,180 KB
testcase_20 AC 52 ms
23,516 KB
testcase_21 AC 51 ms
24,084 KB
testcase_22 AC 51 ms
24,168 KB
testcase_23 AC 52 ms
24,168 KB
testcase_24 AC 52 ms
24,192 KB
testcase_25 AC 52 ms
23,492 KB
testcase_26 AC 53 ms
23,976 KB
testcase_27 AC 52 ms
23,976 KB
testcase_28 AC 52 ms
23,484 KB
testcase_29 AC 51 ms
24,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys


def query_answer(answer):
    print("! {answer:d}".format(answer=answer))
    sys.stdout.flush()


def query_question(question):
    print("? {question:d}".format(question=question))
    sys.stdout.flush()
    if int(input()) == 1:
        return True
    else:
        return False


def solve(left, right):
    mid = (left + right) // 2
    result = query_question(mid)
    if result:
        if right == mid or right - mid == 1:
            query_answer(mid)
        else:
            solve(mid, right)
    else:
        solve(left, mid)


if __name__ == "__main__":
    solve(1, 10**9)
0