結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー arbtarbt
提出日時 2017-09-20 16:03:41
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 459 bytes
コンパイル時間 9,812 ms
コンパイル使用メモリ 429,208 KB
実行使用メモリ 55,468 KB
最終ジャッジ日時 2024-04-30 16:10:18
合計ジャッジ時間 15,514 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 311 ms
55,256 KB
testcase_01 AC 322 ms
55,172 KB
testcase_02 AC 326 ms
55,200 KB
testcase_03 AC 321 ms
55,268 KB
testcase_04 AC 320 ms
55,132 KB
testcase_05 AC 309 ms
55,240 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:15:18: warning: the expression is unused
            1 -> 0
                 ^
Main.kt:29:11: warning: parameter 'argv' is never used
fun main( argv : Array<String> ) {
          ^

ソースコード

diff #

import java.util.Scanner

//
fun _Do() {
    
    val N = scan.nextInt()
    val M = scan.nextInt()
    
    var fib = 0
    var fprev = 0
    var f = 1
    for(i in 1 until N) {
        when (i) {
            1 -> 0
            else -> {
                fib = fprev+f
                fprev = f
                f = fib
            }
        }
    }

    println( fib % M )
  
}

var scan = Scanner(System.`in`)
fun main( argv : Array<String> ) {
    _Do()
}
0