結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー moyaffmoyaff
提出日時 2020-12-31 17:36:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 1,084 bytes
コンパイル時間 1,487 ms
コンパイル使用メモリ 167,496 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-17 22:59:32
合計ジャッジ時間 2,356 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rrep(i,n) for(ll i=n-1; i>=0; i--)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
string zero_padding(int val, int nf){ ostringstream sout;sout << setfill('0') << setw(nf) << val; return sout.str();};
ld PI=asin(1)*2;
//using namespace atcoder;

int main(){ 
    ll N,M;
    cin >> N >> M;
    vector<ll> F(100);
    F[0] = 0;
    F[1] = 1;
    rep(i,N){
        F[(i+2)%100] = F[(i+1)%100] + F[i%100];
        F[(i+2)%100] %= M;
    }
    cout << F[(N-1)%100] << endl;
}
0