結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー nabekonabeko
提出日時 2020-04-16 22:45:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 239 bytes
コンパイル時間 537 ms
コンパイル使用メモリ 64,444 KB
実行使用メモリ 42,652 KB
最終ジャッジ日時 2024-04-10 12:10:33
合計ジャッジ時間 1,473 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 17 ms
11,288 KB
testcase_11 AC 77 ms
42,576 KB
testcase_12 AC 76 ms
42,576 KB
testcase_13 AC 77 ms
42,616 KB
testcase_14 AC 76 ms
42,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
 int main(){
   long long int n,m;
   std::cin >> n >> m;
   long long int dp[n];
   dp[0] = 0;
   dp[1] = 1;
   for(long long int i = 2; i < n; i++) dp[i] = (dp[i-1]+dp[i-2])%m;
   std::cout << dp[n-1] << std::endl;
 }
0