結果
| 問題 |
No.526 フィボナッチ数列の第N項をMで割った余りを求める
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-06-09 23:04:53 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 112 ms / 2,000 ms |
| コード長 | 273 bytes |
| コンパイル時間 | 510 ms |
| コンパイル使用メモリ | 59,652 KB |
| 実行使用メモリ | 42,500 KB |
| 最終ジャッジ日時 | 2024-09-22 17:13:49 |
| 合計ジャッジ時間 | 1,589 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <iostream>
#include <math.h>
using namespace std;
long f[5000000];
int main(){
int a;
int n,m;
int sum = 0;
f[0] = 0;
f[1] = 1;
cin >> n >> m;
for(int i = 2; i < n;++i){
f[i] = (f[i - 2]) % m+(f[i - 1]) % m;
}
cout << f[n-1] % m <<endl;
}