結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー さかぽんさかぽん
提出日時 2021-06-11 11:15:55
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 2,071 ms
コンパイル使用メモリ 103,352 KB
実行使用メモリ 61,224 KB
最終ジャッジ日時 2023-08-20 22:57:38
合計ジャッジ時間 4,279 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
20,916 KB
testcase_01 AC 56 ms
22,720 KB
testcase_02 AC 56 ms
22,708 KB
testcase_03 AC 55 ms
20,692 KB
testcase_04 AC 56 ms
20,788 KB
testcase_05 AC 55 ms
22,776 KB
testcase_06 AC 59 ms
22,872 KB
testcase_07 AC 56 ms
20,676 KB
testcase_08 AC 58 ms
20,752 KB
testcase_09 AC 59 ms
20,904 KB
testcase_10 AC 74 ms
25,964 KB
testcase_11 AC 147 ms
59,252 KB
testcase_12 AC 149 ms
61,224 KB
testcase_13 AC 147 ms
59,108 KB
testcase_14 AC 149 ms
59,156 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class B
{
	static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
	static (int, int) Read2() { var a = Read(); return (a[0], a[1]); }
	static void Main() => Console.WriteLine(Solve());
	static object Solve()
	{
		var (n, m) = Read2();
		return CreateSeqWithMod(n - 1, m)[^1];
	}

	public static long[] CreateSeqWithMod(int nLast, long mod)
	{
		var a = new long[nLast + 1];
		a[1] = 1;
		for (int i = 2; i <= nLast; i++)
			a[i] = (a[i - 1] + a[i - 2]) % mod;
		return a;
	}
}
0