結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー konishikonishi
提出日時 2023-09-02 14:33:47
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 1,396 bytes
コンパイル時間 3,166 ms
コンパイル使用メモリ 244,036 KB
実行使用メモリ 42,332 KB
最終ジャッジ日時 2023-09-02 14:33:51
合計ジャッジ時間 4,389 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<vector<int> > VII;
typedef vector<vector<ll> > VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
//#define int long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pis pair<int,string>
#define psi pair<string,int>
#define rep(i,num,n) for(int i=num;i<(int)(n);i++) //for_loop
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,num,n) for(int i=num-1;i>=(int)(n);i--) //reverse_for>
#define in(x,a,b) (a<=x && x<b)//範囲
#define reo return 0
#define all(v) v.begin(),v.end()
#define INF 2000000000000000000
#define INFL 4000000000000000000
//#define ten(x) ((int)1e##x)
//#define tenll(x) ((ll)1e##x)

#define PI 3.14159265358979
#define mint modint1000000007

//#define mint modint998244353
bool chmin(ll &a,ll b){if(a>b){a=b;return true;}return false;}
bool chmax(ll &a,ll b){if(a<b){a=b;return true;}return false;}
bool chmin(int &a,int b){if(a>b){a=b;return true;}return false;}
bool chmax(int &a,int b){if(a<b){a=b;return true;}return false;}

int main(){
    ll m,n;
    cin>>n>>m;
    vector<ll>fibo(n+10);
    fibo[0]=fibo[1]=0;
    fibo[2]=1;
    rep(i,3,n+1){
        fibo[i]=fibo[i-1]+fibo[i-2];
        fibo[i]%=m;
    }
    cout<<fibo[n];
    
}
0