結果

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<cstring>

using namespace std;

int main(){

	int N,M;
	int a,b,c;

	cin>>N>>M;

	a=0,b=1,c=0;

	for(int i=3;i<=N;i++){
		c=a+b;
		c=c%M;
		a=b%M;
		b=c%M;
	}

	cout<<b<<endl;
	
}
0