結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー MNghr
提出日時 2017-06-09 23:00:55
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 271 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 59,544 KB
実行使用メモリ 42,444 KB
最終ジャッジ日時 2024-09-22 16:50:26
合計ジャッジ時間 1,219 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other AC * 1 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#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){
		sum += f[i - 2]+f[i - 1];
		f[i] = sum;
	}

	cout << sum % m <<endl;
	
}
0