結果
問題 |
No.526 フィボナッチ数列の第N項をMで割った余りを求める
|
ユーザー |
|
提出日時 | 2021-05-18 10:59:36 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 120 ms / 2,000 ms |
コード長 | 406 bytes |
コンパイル時間 | 930 ms |
コンパイル使用メモリ | 111,452 KB |
実行使用メモリ | 56,064 KB |
最終ジャッジ日時 | 2024-10-08 07:55:18 |
合計ジャッジ時間 | 2,706 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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(); var dp = new long[n]; dp[1] = 1; for (int i = 2; i < n; i++) dp[i] = (dp[i - 2] + dp[i - 1]) % m; return dp[^1]; } }