結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー mikan765mikan765
提出日時 2017-09-25 13:26:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 521 bytes
コンパイル時間 632 ms
コンパイル使用メモリ 77,056 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 21:46:45
合計ジャッジ時間 1,568 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,940 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 18 ms
6,944 KB
testcase_11 WA -
testcase_12 AC 81 ms
6,944 KB
testcase_13 WA -
testcase_14 AC 82 ms
6,944 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;
    int now =0;
    int past =1;
    rep(i,n-1){
        ll tmp=now;
        now = (now + past)%m;
        past = tmp;
    }
    P(now);
}
0