結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー NoNo
提出日時 2017-06-10 08:26:23
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 499 bytes
コンパイル時間 2,227 ms
コンパイル使用メモリ 107,732 KB
実行使用メモリ 74,404 KB
最終ジャッジ日時 2023-10-24 20:21:53
合計ジャッジ時間 3,557 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
23,972 KB
testcase_01 AC 23 ms
23,972 KB
testcase_02 AC 25 ms
23,972 KB
testcase_03 AC 24 ms
23,972 KB
testcase_04 AC 24 ms
23,972 KB
testcase_05 AC 23 ms
23,972 KB
testcase_06 AC 23 ms
23,972 KB
testcase_07 AC 24 ms
23,972 KB
testcase_08 AC 23 ms
23,972 KB
testcase_09 AC 25 ms
23,996 KB
testcase_10 AC 41 ms
30,984 KB
testcase_11 WA -
testcase_12 AC 109 ms
74,400 KB
testcase_13 WA -
testcase_14 AC 114 ms
74,400 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.Collections.Generic;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            int m = int.Parse(ss[1]);
            var f = new List<int>() { 0, 1 };
            for (int i = 2; i < n; i++)
            {
                f.Add((f[i - 2] + f[i - 1]) % m);
            }
            Console.WriteLine(f[n - 1]);
        }
    }
}
0