結果
問題 |
No.526 フィボナッチ数列の第N項をMで割った余りを求める
|
ユーザー |
|
提出日時 | 2019-07-03 12:02:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 90 ms / 2,000 ms |
コード長 | 241 bytes |
コンパイル時間 | 643 ms |
コンパイル使用メモリ | 71,000 KB |
実行使用メモリ | 42,576 KB |
最終ジャッジ日時 | 2024-09-14 17:54:46 |
合計ジャッジ時間 | 1,983 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include<iostream> #include<algorithm> #include<cmath> using namespace std; int main() { long long n,m,f[5000050]; cin >> n >> m; f[1]=0; f[2]=1; for(int i=3; i<=n; i++) { f[i]=(f[i-1]+f[i-2])%m; } cout << f[n] << endl; }