結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー TaK7907TaK7907
提出日時 2017-11-03 07:25:13
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 965 bytes
コンパイル時間 942 ms
コンパイル使用メモリ 106,240 KB
実行使用メモリ 119,020 KB
最終ジャッジ日時 2024-05-02 04:29:55
合計ジャッジ時間 2,705 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
18,560 KB
testcase_01 AC 22 ms
18,560 KB
testcase_02 AC 23 ms
18,560 KB
testcase_03 AC 22 ms
18,688 KB
testcase_04 AC 23 ms
18,688 KB
testcase_05 AC 23 ms
18,560 KB
testcase_06 WA -
testcase_07 AC 22 ms
18,688 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 141 ms
118,764 KB
testcase_13 WA -
testcase_14 AC 145 ms
118,632 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;
using System.Linq;

namespace yukicode {
    public class Program {
        static List<UInt64> Fibonatch = new List<UInt64>();
        public static void MakeFibonatchSequence(int n) {
            if (Fibonatch.Count == 0) Fibonatch.Add( 0 );
            if (Fibonatch.Count == 1) Fibonatch.Add( 1 );
            if (n < 2) return;
            for (var i = 2; i <= n; ++i) {
                if (Fibonatch.Count == i) {
                    Fibonatch.Add( Fibonatch[ i - 1 ] + Fibonatch[ i - 2 ] );
                }
            }
        }
        public static UInt64 Solver(System.IO.TextReader reader) {
            var n = reader.ReadLine().Split().ToList().ConvertAll( int.Parse );
            MakeFibonatchSequence( n[ 0 ] - 1 );
            return Fibonatch[ n[ 0 ] - 1 ] % (UInt64)n[ 1 ];
        }

        private static void Main() {
            Console.WriteLine( Solver( Console.In ) );
        }
    }
}
0