結果

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

ソースコード

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] = ((long long) dp[i - 2] + dp[i - 1]) % M;
	}
	cout << dp[N - 1] << endl;
}
0