結果
問題 |
No.526 フィボナッチ数列の第N項をMで割った余りを求める
|
ユーザー |
|
提出日時 | 2017-11-03 07:25:13 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 965 bytes |
コンパイル時間 | 4,047 ms |
コンパイル使用メモリ | 105,216 KB |
実行使用メモリ | 118,764 KB |
最終ジャッジ日時 | 2024-11-22 15:00:45 |
合計ジャッジ時間 | 4,239 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 6 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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 ) ); } } }