結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー mmn15277198mmn15277198
提出日時 2020-06-06 19:44:04
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 81,744 KB
実行使用メモリ 42,300 KB
最終ジャッジ日時 2023-08-25 01:48:17
合計ジャッジ時間 1,588 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,500 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 22 ms
42,184 KB
testcase_13 WA -
testcase_14 AC 22 ms
42,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<deque>
using namespace std;

int main(){
	unsigned long long n,m;
	cin >> n >> m;
	vector<unsigned long long> a(n);
	for(long long i=0;i<n;i++){
		if(i==0){
			a[i]=0;
		}else if(i==1){
			a[i]=1;
		}else{
			a[i]=a[i-1]+a[i-2];
		}
	}
	unsigned long long ans=a[n-1]%m;
	cout << ans << endl;
	return 0;
}

0