結果

問題 No.253 ロウソクの長さ
ユーザー jitomeskyjitomesky
提出日時 2015-08-01 18:23:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,146 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 11,032 KB
実行使用メモリ 24,680 KB
平均クエリ数 32.06
最終ジャッジ日時 2023-09-23 05:35:54
合計ジャッジ時間 5,609 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
24,232 KB
testcase_01 AC 42 ms
24,468 KB
testcase_02 AC 43 ms
24,060 KB
testcase_03 AC 42 ms
24,044 KB
testcase_04 AC 42 ms
23,996 KB
testcase_05 AC 43 ms
24,264 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 40 ms
24,144 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 41 ms
24,024 KB
testcase_13 WA -
testcase_14 AC 43 ms
24,272 KB
testcase_15 AC 45 ms
24,220 KB
testcase_16 AC 42 ms
23,968 KB
testcase_17 AC 41 ms
24,096 KB
testcase_18 WA -
testcase_19 AC 41 ms
24,396 KB
testcase_20 WA -
testcase_21 AC 43 ms
24,208 KB
testcase_22 AC 41 ms
24,500 KB
testcase_23 AC 41 ms
24,576 KB
testcase_24 AC 45 ms
24,168 KB
testcase_25 WA -
testcase_26 AC 41 ms
24,092 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 42 ms
24,052 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 42 ms
24,152 KB
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math

def question(num):
    print("? %d" % num)
    sys.stdout.flush()
    n = int(input())
    return n

def result(num):
    print("! %d" % num)
    sys.stdout.flush()

def first_step(i, max_num, min_num):
    judge = int(max_num / 2)
    
    for i in range(i, 28):
        r = question(judge)
        if r == 1:
            # higer
            min_num = judge
        elif r == -1:
            # low
            max_num = judge
        else:
            return 1000, (judge+i)
        max_num -= 1
        min_num -= 1
        judge = int((max_num - min_num) / 2) + min_num
    return i, min_num

def second_step(i, judge):
    for i in range(i, 100 - i):
        r = question(judge)
        if r == 0:
            break
    return i + judge


# main
max_num = 1e9
judge = int(max_num / 2)
min_num = 10

# less than 100?
r = question(100)
max_num -= 1
min_num -= 1

if r == -1:
    r = second_step(1, min_num)
elif r == 1:
    min_num = 100 - 1
    i, min_num = first_step(1, max_num, min_num)
    if i > 100:
        r = min_num
    else:
        r = second_step(i, min_num)
else:
    r = 100

# 答えを出力
result(r)
0