結果

問題 No.554 recurrence formula
ユーザー 💕💖💞💕💖💞
提出日時 2017-09-08 21:34:25
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 316 ms / 2,000 ms
コード長 383 bytes
コンパイル時間 9,330 ms
コンパイル使用メモリ 430,700 KB
実行使用メモリ 69,628 KB
最終ジャッジ日時 2024-04-30 15:42:32
合計ジャッジ時間 16,156 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 255 ms
56,876 KB
testcase_01 AC 259 ms
56,900 KB
testcase_02 AC 259 ms
56,852 KB
testcase_03 AC 266 ms
56,768 KB
testcase_04 AC 257 ms
56,872 KB
testcase_05 AC 255 ms
56,744 KB
testcase_06 AC 272 ms
56,872 KB
testcase_07 AC 264 ms
56,848 KB
testcase_08 AC 260 ms
56,776 KB
testcase_09 AC 262 ms
56,744 KB
testcase_10 AC 264 ms
56,904 KB
testcase_11 AC 269 ms
57,012 KB
testcase_12 AC 261 ms
56,924 KB
testcase_13 AC 289 ms
57,000 KB
testcase_14 AC 275 ms
56,916 KB
testcase_15 AC 296 ms
56,968 KB
testcase_16 AC 286 ms
57,220 KB
testcase_17 AC 284 ms
57,096 KB
testcase_18 AC 287 ms
57,140 KB
testcase_19 AC 316 ms
69,628 KB
testcase_20 AC 314 ms
69,592 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