結果

問題 No.554 recurrence formula
ユーザー 💕💖💞💕💖💞
提出日時 2017-09-08 21:34:25
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 363 ms / 2,000 ms
コード長 383 bytes
コンパイル時間 10,713 ms
コンパイル使用メモリ 417,680 KB
実行使用メモリ 62,192 KB
最終ジャッジ日時 2023-08-12 20:37:15
合計ジャッジ時間 18,344 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 276 ms
52,832 KB
testcase_01 AC 273 ms
52,920 KB
testcase_02 AC 274 ms
52,868 KB
testcase_03 AC 284 ms
52,952 KB
testcase_04 AC 274 ms
52,912 KB
testcase_05 AC 285 ms
52,808 KB
testcase_06 AC 273 ms
53,092 KB
testcase_07 AC 277 ms
52,904 KB
testcase_08 AC 270 ms
52,776 KB
testcase_09 AC 268 ms
52,944 KB
testcase_10 AC 281 ms
52,880 KB
testcase_11 AC 286 ms
52,976 KB
testcase_12 AC 278 ms
52,968 KB
testcase_13 AC 301 ms
53,056 KB
testcase_14 AC 276 ms
52,884 KB
testcase_15 AC 307 ms
53,124 KB
testcase_16 AC 299 ms
52,944 KB
testcase_17 AC 301 ms
52,940 KB
testcase_18 AC 303 ms
53,096 KB
testcase_19 AC 363 ms
61,940 KB
testcase_20 AC 357 ms
62,192 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:11: warning: parameter 'args' is never used
fun main( args : Array<String> ) {
          ^

ソースコード

diff #

fun main( args : Array<String> ) {
  val ns = mutableMapOf<Int, Long>(1 to 1L)
  var odd = 0L
  var even = 1L
  val n = readLine()!!.toInt()
  val L = 1000_000_007L
  (2..n).map { i ->
    when {
      i%2 == 0 -> { 
        ns[i] = i*even%L
        odd += ns[i]!!
      }
      else -> {
        ns[i] = i*odd%L
        even += ns[i]!!
      }
    }
  }
  println( ns[n]!!%L )
  
}
0