結果

問題 No.378 名声値を稼ごう
ユーザー nobigomunobigomu
提出日時 2018-06-04 12:33:01
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 265 ms / 2,000 ms
コード長 367 bytes
コンパイル時間 11,513 ms
コンパイル使用メモリ 416,768 KB
実行使用メモリ 50,336 KB
最終ジャッジ日時 2023-09-12 22:05:42
合計ジャッジ時間 14,527 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 262 ms
50,336 KB
testcase_01 AC 261 ms
50,136 KB
testcase_02 AC 265 ms
50,020 KB
testcase_03 AC 263 ms
50,284 KB
testcase_04 AC 264 ms
49,996 KB
testcase_05 AC 263 ms
50,148 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:6:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

diff #

fun max(a: Long, b: Long): Long = if (a>b) a else b
fun abs(a: Long): Long = if (a<0) -a else a
fun f(a: Long): Long = a shr 1
fun g(a: Long): Long = (f(a) shl 1) + a
tailrec fun h(a: Long, b: Long, c: Long): Long = if (a>0) h(f(a),b+f(a),max(c,g(a))) else abs(c-b)
fun main(args: Array<String>) {
    val n: Long = readLine()!!.toLong()
    println(h(n,n,n shl 1))
}
0