結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
コンテスト
ユーザー Maeda
提出日時 2025-03-27 14:24:27
言語 C
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 324 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 51 ms
コンパイル使用メモリ 35,840 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-23 16:56:06
合計ジャッジ時間 1,311 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
void main(void){
    int n = 0 , m = 0;
    scanf("%d %d",&n,&m);

     long long int lastTime = 0 , total = 1 ,result = (lastTime + total) % m;
    for(int i = 3 ; i < n ; i++){
        lastTime = total;
        total = result;
        result = (lastTime + total) % m;
    }
    printf("%lld",result);
}
0