結果
問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める |
ユーザー | mosmos_21 |
提出日時 | 2017-06-10 20:42:39 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 347 bytes |
コンパイル時間 | 3,237 ms |
コンパイル使用メモリ | 74,092 KB |
実行使用メモリ | 57,548 KB |
最終ジャッジ日時 | 2023-10-24 20:35:07 |
合計ジャッジ時間 | 7,462 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 120 ms
57,512 KB |
testcase_01 | AC | 121 ms
57,544 KB |
testcase_02 | AC | 129 ms
57,548 KB |
testcase_03 | AC | 121 ms
57,412 KB |
testcase_04 | AC | 137 ms
57,504 KB |
testcase_05 | AC | 1,223 ms
57,232 KB |
testcase_06 | TLE | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
ソースコード
import java.util.Scanner; public class Main { static Scanner in = new Scanner(System.in); public static void main(String[] args){ int n = in.nextInt(), m = in.nextInt(); System.out.println(f(n, m) % m); } public static int f(int n, int m){ if(n == 1) return 0; if(n == 2) return 1; else return f(n - 1, m) + f(n - 2, m) % m; } }