結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
コンテスト
ユーザー くれちー
提出日時 2017-04-04 12:58:27
言語 C#(csc)
(csc 3.9.0)
コンパイル:
csc -langversion:latest -unsafe -warn:0 -o+ /r:System.Numerics.dll _filename_ -out:a.exe
実行:
/usr/bin/mono a.exe
結果
TLE  
実行時間 -
コード長 456 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 523 ms
コンパイル使用メモリ 104,192 KB
実行使用メモリ 66,268 KB
最終ジャッジ日時 2026-03-30 01:49:16
合計ジャッジ時間 4,559 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 TLE * 1 -- * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #
raw source code

using System;
using System.Numerics;

class Program
{
    static void Main()
    {
        var strs = Console.ReadLine().Split();
        var n = int.Parse(strs[0]);
        var m = BigInteger.Parse(strs[1]);
        var fib = new BigInteger[3] { 0, 1, 1 };
        for (var i = 3; i < n; i++)
        {
            fib[0] = fib[1];
            fib[1] = fib[2];
            fib[2] = fib[0] + fib[1];
        }
        Console.WriteLine(fib[2] % m);
    }
}
0