結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー mosmos_21mosmos_21
提出日時 2017-06-09 22:26:58
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 327 bytes
コンパイル時間 2,236 ms
コンパイル使用メモリ 74,080 KB
実行使用メモリ 62,664 KB
最終ジャッジ日時 2023-10-23 21:39:59
合計ジャッジ時間 7,306 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
57,428 KB
testcase_01 AC 123 ms
57,432 KB
testcase_02 AC 124 ms
57,428 KB
testcase_03 AC 121 ms
57,584 KB
testcase_04 AC 129 ms
57,564 KB
testcase_05 AC 795 ms
57,292 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
	}
	
	public static int f(int n){
		if(n == 1) return 0;
		if(n == 2) return 1;
		else return f(n - 1) + f(n - 2);
	}
}
0