結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー ducktailducktail
提出日時 2017-12-28 21:01:15
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 327 ms / 2,000 ms
コード長 242 bytes
コンパイル時間 40 ms
コンパイル使用メモリ 5,300 KB
実行使用メモリ 11,868 KB
最終ジャッジ日時 2023-08-23 08:13:38
合計ジャッジ時間 2,647 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
11,848 KB
testcase_01 AC 18 ms
11,848 KB
testcase_02 AC 21 ms
11,680 KB
testcase_03 AC 19 ms
11,764 KB
testcase_04 AC 18 ms
11,684 KB
testcase_05 AC 16 ms
11,856 KB
testcase_06 AC 17 ms
11,868 KB
testcase_07 AC 17 ms
11,860 KB
testcase_08 AC 18 ms
11,664 KB
testcase_09 AC 23 ms
11,648 KB
testcase_10 AC 80 ms
11,776 KB
testcase_11 AC 326 ms
11,776 KB
testcase_12 AC 326 ms
11,684 KB
testcase_13 AC 327 ms
11,664 KB
testcase_14 AC 326 ms
11,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

(define (fib n m)
  (let loop ([x n]
             [a 0]
             [b 1])
    (if (= x 1)
        a
        (loop (- x 1) b (remainder (+ a b) m)))))

(define (main args)
  (let* ([n (read)]
         [m (read)])
    (print (fib n m)))
  0)
0