結果

問題 No.253 ロウソクの長さ
ユーザー MamonboMamonbo
提出日時 2015-08-20 15:32:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 1,131 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 10,820 KB
実行使用メモリ 24,408 KB
平均クエリ数 20.86
最終ジャッジ日時 2023-09-23 21:20:37
合計ジャッジ時間 3,917 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
23,408 KB
testcase_01 AC 40 ms
24,036 KB
testcase_02 AC 41 ms
24,060 KB
testcase_03 AC 42 ms
23,892 KB
testcase_04 AC 41 ms
23,460 KB
testcase_05 AC 41 ms
24,324 KB
testcase_06 AC 42 ms
23,448 KB
testcase_07 AC 43 ms
23,608 KB
testcase_08 AC 43 ms
24,336 KB
testcase_09 AC 41 ms
24,068 KB
testcase_10 AC 43 ms
24,096 KB
testcase_11 AC 43 ms
24,084 KB
testcase_12 AC 43 ms
23,568 KB
testcase_13 AC 44 ms
24,060 KB
testcase_14 AC 43 ms
23,572 KB
testcase_15 AC 41 ms
24,408 KB
testcase_16 AC 41 ms
23,736 KB
testcase_17 AC 42 ms
23,436 KB
testcase_18 AC 43 ms
23,652 KB
testcase_19 AC 44 ms
24,096 KB
testcase_20 AC 43 ms
24,060 KB
testcase_21 AC 41 ms
23,588 KB
testcase_22 AC 42 ms
23,448 KB
testcase_23 AC 43 ms
23,460 KB
testcase_24 AC 41 ms
24,360 KB
testcase_25 AC 42 ms
23,856 KB
testcase_26 AC 43 ms
23,420 KB
testcase_27 AC 42 ms
24,276 KB
testcase_28 AC 41 ms
23,856 KB
testcase_29 AC 43 ms
23,700 KB
testcase_30 AC 43 ms
23,796 KB
testcase_31 AC 42 ms
24,096 KB
testcase_32 AC 42 ms
24,396 KB
testcase_33 AC 44 ms
23,760 KB
testcase_34 AC 43 ms
23,748 KB
testcase_35 AC 41 ms
23,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#coding=UTF-8

#log_2 10^9=29.89だそうな
#100以上なら(わりかし)普通の二分探索でやるだけの話
#1 cmとかいうevilなのが無いのが救いか
#100未満の場合はあと9回で 楽勝でしょ
#ユキコちゃんとのやりとりのしかたはNo.246(URIは551)を参考に
import sys

ans=1
jogen=10**9
kagen=10
burnt=0

print('? 100')
sys.stdout.flush()
res = int(input())
if res==0:
    kagen=100
    jogen=100
elif res==1:
    kagen=100+1
else:
    jogen=100-1
burnt=burnt+1


while not (jogen-kagen<=1):
    print ("? "+str((jogen+kagen)//2-burnt))
    sys.stdout.flush()
    res = int(input())
    if res==0:
        kagen=(jogen+kagen)//2
        jogen=kagen
    elif res==1:
        kagen=(jogen+kagen)//2+1
    else:
        jogen=(jogen+kagen)//2-1
    burnt=burnt+1

#    print((jogen,kagen))

if jogen-kagen==1:
    print("? "+str(jogen-burnt))
    sys.stdout.flush()
    res=int(input())
    if res==0:
        ans=jogen
    else:
        ans=kagen
else:
    ans=jogen
print("! "+str(ans))
sys.stdout.flush()
#質問する数を変数に仕舞っておくと良かったかもしれない
0