結果
| 問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-11 11:15:55 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 121 ms / 2,000 ms |
| コード長 | 517 bytes |
| 記録 | |
| コンパイル時間 | 1,106 ms |
| コンパイル使用メモリ | 112,684 KB |
| 実行使用メモリ | 56,192 KB |
| 最終ジャッジ日時 | 2024-12-14 05:55:41 |
| 合計ジャッジ時間 | 2,947 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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;
}
}