結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー NarumisakakiosNarumisakakios
提出日時 2021-07-14 05:00:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 315 bytes
コンパイル時間 1,374 ms
コンパイル使用メモリ 165,980 KB
実行使用メモリ 42,344 KB
最終ジャッジ日時 2023-09-16 01:30:41
合計ジャッジ時間 2,990 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 39 ms
10,924 KB
testcase_11 AC 186 ms
42,272 KB
testcase_12 AC 184 ms
42,056 KB
testcase_13 AC 181 ms
42,208 KB
testcase_14 AC 177 ms
42,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//okita
int main(){
   ll N,M;cin>>N>>M;
   vector<ll> F(N);
   F[0]=0;
   F[1]=1;
   for(ll i=2;i<N;i++){
       F[i]=(F[i-1]%M)+(F[i-2]%M);
       F[i]=F[i]%M;
   }
   cout<<F[N-1]%M<<endl;
}
0