結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー 💕💖💞💕💖💞
提出日時 2017-06-24 15:40:54
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 1,403 ms / 2,000 ms
コード長 250 bytes
コンパイル時間 13,473 ms
コンパイル使用メモリ 417,960 KB
実行使用メモリ 297,328 KB
最終ジャッジ日時 2023-08-12 19:16:28
合計ジャッジ時間 24,187 ms
ジャッジサーバーID
(参考情報)
judge7 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 305 ms
52,868 KB
testcase_01 AC 297 ms
53,032 KB
testcase_02 AC 306 ms
52,732 KB
testcase_03 AC 296 ms
52,848 KB
testcase_04 AC 294 ms
52,776 KB
testcase_05 AC 298 ms
52,876 KB
testcase_06 AC 295 ms
52,740 KB
testcase_07 AC 306 ms
52,936 KB
testcase_08 AC 314 ms
52,956 KB
testcase_09 AC 338 ms
55,780 KB
testcase_10 AC 447 ms
90,672 KB
testcase_11 AC 1,403 ms
297,116 KB
testcase_12 AC 781 ms
119,828 KB
testcase_13 AC 1,400 ms
297,328 KB
testcase_14 AC 1,400 ms
296,976 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

diff #

fun main(args: Array<String>) {
  val (n,m) = readLine()!!.split(" ").map { x -> x.toLong() }

  val fs = mutableListOf<Long>(0, 1)
  (2..n-1).map {
    val next = fs[fs.size-1] + fs[fs.size-2]
    fs.add( next%m )
  }
  println( fs[fs.size-1]%m )
}
0