結果

問題 No.253 ロウソクの長さ
ユーザー yaoshimax
提出日時 2016-05-08 13:12:27
言語 Python2
(2.7.18)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 481 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 25,460 KB
平均クエリ数 21.47
最終ジャッジ日時 2024-07-16 23:41:37
合計ジャッジ時間 3,463 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

left=10
right=1000000001
print "? %d" % 512
sys.stdout.flush()
res=int(raw_input())
if res>0:
    left=513
elif res<0:
    right=511
else:
    print "! %d" % 512
    sys.stdout.flush()
    exit()

t=1
while left < right:
    mid=(left+right)/2
    print "? %d" % (mid-t)
    sys.stdout.flush()
    res=int(raw_input())
    if res>0:
        left=mid+1
    elif res<0:
        right=mid-1
    else:
        left=right=mid
    t+=1
print "! %d" % left
sys.stdout.flush()
0