結果

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

テストケース

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

ソースコード

diff #

fun readLong(): Long = readLine()!!.toLong()
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/2L
fun g(a: Long): Long = 2L*f(a)+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 = readLong()
    println(h(n,n,2L*n))
}
0