結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー mikan765mikan765
提出日時 2017-09-25 13:27:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 639 ms
コンパイル使用メモリ 76,924 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 21:46:47
合計ジャッジ時間 1,470 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 18 ms
5,376 KB
testcase_11 AC 80 ms
5,376 KB
testcase_12 AC 72 ms
5,376 KB
testcase_13 AC 78 ms
5,376 KB
testcase_14 AC 71 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <stdio.h>
#include <string>
#include <list>
#include <vector>
#include <algorithm>

#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;//print
typedef long long ll;
using namespace std;


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    ll n,m;
    cin >> n >> m;
    ll now =0;
    ll past =1;
    rep(i,n-1){
        ll tmp=now;
        now = (now + past)%m;
        past = tmp;
    }
    P(now);
}
0