結果

問題 No.253 ロウソクの長さ
コンテスト
ユーザー nebukuro09
提出日時 2016-10-02 19:21:35
言語 PyPy2
(7.3.20)
コンパイル:
pypy2 -m py_compile _filename_
実行:
/usr/bin/pypy2 Main.pyc
結果
AC  
実行時間 178 ms / 2,000 ms
+ 1µs
コード長 484 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 57 ms
コンパイル使用メモリ 80,956 KB
実行使用メモリ 81,152 KB
平均クエリ数 21.11
最終ジャッジ日時 2026-07-18 08:53:24
合計ジャッジ時間 4,016 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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