結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー 💕💖💞💕💖💞
提出日時 2017-06-24 15:40:54
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 1,008 ms / 2,000 ms
コード長 250 bytes
コンパイル時間 11,405 ms
コンパイル使用メモリ 439,960 KB
実行使用メモリ 276,584 KB
最終ジャッジ日時 2024-04-30 14:21:46
合計ジャッジ時間 17,528 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 307 ms
57,112 KB
testcase_01 AC 290 ms
57,096 KB
testcase_02 AC 293 ms
56,968 KB
testcase_03 AC 288 ms
57,064 KB
testcase_04 AC 295 ms
57,072 KB
testcase_05 AC 282 ms
57,016 KB
testcase_06 AC 276 ms
57,224 KB
testcase_07 AC 283 ms
57,020 KB
testcase_08 AC 279 ms
56,992 KB
testcase_09 AC 309 ms
61,168 KB
testcase_10 AC 364 ms
101,140 KB
testcase_11 AC 1,008 ms
276,584 KB
testcase_12 AC 497 ms
168,520 KB
testcase_13 AC 990 ms
276,536 KB
testcase_14 AC 988 ms
276,456 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