結果
| 問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-12-15 07:01:28 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 2,000 ms |
| コード長 | 302 bytes |
| 記録 | |
| コンパイル時間 | 1,396 ms |
| コンパイル使用メモリ | 208,156 KB |
| 実行使用メモリ | 42,752 KB |
| 最終ジャッジ日時 | 2026-06-24 17:40:29 |
| 合計ジャッジ時間 | 2,574 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
long long int f[5000001];
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
long long int n,m;
cin >> n >> m;
f[1] = 0;
f[2] = 1;
for(int i=3;i<=n;i++)
{
f[i] = f[i-1] + f[i-2];
f[i]%=m;
}
cout << f[n] << '\n';
return 0;
}