結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー SSRS
提出日時 2020-08-24 07:19:18
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 243 bytes
コンパイル時間 708 ms
コンパイル使用メモリ 68,736 KB
実行使用メモリ 22,884 KB
最終ジャッジ日時 2024-11-06 02:50:32
合計ジャッジ時間 1,618 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(){
	int N, M;
	cin >> N >> M;
	vector<int> dp(N);
	dp[0] = 0;
	dp[1] = 1;
	for (int i = 2; i < N; i++){
		dp[i] = (dp[i - 2] + dp[i - 1]) % M;
	}
	cout << dp[N - 1] << endl;
}
0