結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー csctcycle
提出日時 2024-02-24 00:41:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 231 bytes
コンパイル時間 1,873 ms
コンパイル使用メモリ 165,196 KB
実行使用メモリ 42,528 KB
最終ジャッジ日時 2024-09-29 09:36:47
合計ジャッジ時間 2,662 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int maxn = 5e6+7;
using ll = long long;
ll A[maxn];
int n,m;

int main()
{
	cin>>n>>m;
	
	A[1]=0;A[2]=1;
	for(int i=3;i<=n;i++)
	A[i]=(A[i-1]+A[i-2])%m;
	
	cout<<A[n];
	return 0;
}
0