結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー arbtarbt
提出日時 2017-09-26 21:39:10
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 481 bytes
コンパイル時間 11,547 ms
コンパイル使用メモリ 428,296 KB
実行使用メモリ 55,420 KB
最終ジャッジ日時 2024-04-30 16:14:05
合計ジャッジ時間 16,711 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 321 ms
55,148 KB
testcase_01 AC 327 ms
55,252 KB
testcase_02 AC 329 ms
55,272 KB
testcase_03 AC 326 ms
55,260 KB
testcase_04 AC 323 ms
55,248 KB
testcase_05 AC 339 ms
55,236 KB
testcase_06 AC 321 ms
55,288 KB
testcase_07 AC 344 ms
55,264 KB
testcase_08 AC 333 ms
55,356 KB
testcase_09 AC 322 ms
55,280 KB
testcase_10 AC 336 ms
55,312 KB
testcase_11 WA -
testcase_12 AC 387 ms
55,268 KB
testcase_13 WA -
testcase_14 AC 387 ms
55,176 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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()
    
    println(when(N){
        1 -> 0
        2 -> 1
        else -> {
            var f1 = 0
            var f2 = 1
            var f=1
            for (i in 3..N) {
                f = (f1+f2) % M
                f1 = f2 % M
                f2 = f
            }
            f
        }
    })
}

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