結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 12 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 52 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 50 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);
    
    int n,m;
    cin >> n >> m;
    int now =0;
    int past =1;
    rep(i,n-1){
        int tmp=now;
        now = (now + past)%m;
        past = tmp;
    }
    P(now);
}
0