結果

問題 No.253 ロウソクの長さ
コンテスト
ユーザー nebukuro09
提出日時 2016-10-02 19:21:35
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 484 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 156 ms
コンパイル使用メモリ 77,608 KB
最終ジャッジ日時 2025-12-03 21:42:12
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys

def ask(n):
    print '?', n
    sys.stdout.flush()
    return int(raw_input())

def ans(n):
    print '!', n
    sys.stdout.flush()
    exit()

res = ask(100)
if res == 0:
    ans(100)
high = 100 if res < 0 else 10**9
low = 0
i = 1

while high - low > 1:
    mid = (high+low)/2
    res = ask(mid-i)
    if res == 0:
        ans(mid)
    if res > 0:
        low = mid
    else:
        high = mid
    i += 1

res = ask(low-i)
if res == 0:
    ans(low)
else:
    ans(high)
0