結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー RonlynesRonlynes
提出日時 2017-06-09 22:37:22
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 321 bytes
コンパイル時間 1,726 ms
コンパイル使用メモリ 57,272 KB
実行使用メモリ 8,744 KB
最終ジャッジ日時 2023-10-23 22:08:59
合計ジャッジ時間 6,441 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;

long long sum = 0;
long long fib(int n){
    
    if(n == 1){
        return 0;
    }
    if(n == 2){
        return 1;
    }
    return fib(n-1) + fib(n-2);
}
int main(void){
    long long n, m;
    cin >> n >> m;

    cout << fib(n)%m << endl;
    return 0;
}
0