結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー RonlynesRonlynes
提出日時 2017-06-09 22:46:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 343 bytes
コンパイル時間 609 ms
コンパイル使用メモリ 55,704 KB
実行使用メモリ 42,712 KB
最終ジャッジ日時 2023-10-23 22:16:51
合計ジャッジ時間 1,701 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;

long long fib(long long num) {
	long long dp[5000001]; //計算結果を入れる
	dp[0] = 0;
	dp[1] = 1;
	for (int i = 2; i <= num-1; i++) {
		dp[i] = dp[i - 1] + dp[i - 2];
	}
	return dp[num-1];
}

int main(void){
    long long n, m;
    cin >> n >> m;

    cout << fib(n)%m << endl;
    return 0;
}
0