結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー ebicochinealebicochineal
提出日時 2017-07-05 05:57:02
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 392 bytes
コンパイル時間 1,039 ms
コンパイル使用メモリ 105,728 KB
実行使用メモリ 27,268 KB
最終ジャッジ日時 2024-04-15 16:49:34
合計ジャッジ時間 2,742 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
25,008 KB
testcase_01 AC 30 ms
27,268 KB
testcase_02 AC 30 ms
24,880 KB
testcase_03 AC 30 ms
25,104 KB
testcase_04 AC 30 ms
27,152 KB
testcase_05 AC 30 ms
27,148 KB
testcase_06 AC 30 ms
25,008 KB
testcase_07 AC 29 ms
25,140 KB
testcase_08 AC 30 ms
25,016 KB
testcase_09 AC 31 ms
25,004 KB
testcase_10 AC 46 ms
27,188 KB
testcase_11 AC 113 ms
25,096 KB
testcase_12 AC 111 ms
27,144 KB
testcase_13 AC 111 ms
24,972 KB
testcase_14 AC 110 ms
25,396 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