結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー ebicochinealebicochineal
提出日時 2017-07-05 05:57:02
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 392 bytes
コンパイル時間 2,235 ms
コンパイル使用メモリ 104,916 KB
実行使用メモリ 23,976 KB
最終ジャッジ日時 2023-07-28 07:30:17
合計ジャッジ時間 4,769 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
23,840 KB
testcase_01 AC 61 ms
23,824 KB
testcase_02 AC 61 ms
21,784 KB
testcase_03 AC 60 ms
21,860 KB
testcase_04 AC 61 ms
21,988 KB
testcase_05 AC 60 ms
21,800 KB
testcase_06 AC 61 ms
21,880 KB
testcase_07 AC 61 ms
21,884 KB
testcase_08 AC 61 ms
21,784 KB
testcase_09 AC 62 ms
21,860 KB
testcase_10 AC 78 ms
21,876 KB
testcase_11 AC 142 ms
23,976 KB
testcase_12 AC 140 ms
21,796 KB
testcase_13 AC 141 ms
19,852 KB
testcase_14 AC 140 ms
22,004 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;

public class Program {
    static void Main(string[] args) {
        var L = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();
        int N = L[0], M = L[1];
        long a = 1, b = 0, t;
        for (int i = 0; i < N - 2; ++i) {
            t = a;
            a = (a + b) % M;
            b = t;
        }
        Console.WriteLine(a);
    }
}
0