結果

問題 No.253 ロウソクの長さ
ユーザー mura40424mura40424
提出日時 2015-08-01 17:53:14
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 450 bytes
コンパイル時間 11,226 ms
コンパイル使用メモリ 411,736 KB
実行使用メモリ 69,284 KB
平均クエリ数 312.83
最終ジャッジ日時 2023-09-23 05:33:45
合計ジャッジ時間 29,877 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 RE -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 RE -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:23:10: warning: parameter 'args' is never used
fun main(args : Array<String>) {
         ^

ソースコード

diff #

var MAX = Math.pow(10.0,9.0).toInt() + 1
var count = 0

fun askCandle(left : Int, right : Int) {
    count++
    var x = (left + right) / 2

    println("? " + x.toInt())
    var ans = readLine()!!.toInt()

    if(ans == 1) {
        askCandle(x - 1, right)
    }
    else if(ans == -1){
        askCandle(left, x - 2)
    }
    else {
        println("! " + x + count)
        return
    }
}

fun main(args : Array<String>) {
    askCandle(0, MAX)
}
0