結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー snzt_ptsnzt_pt
提出日時 2017-06-22 11:34:38
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 435 bytes
コンパイル時間 1,864 ms
コンパイル使用メモリ 74,424 KB
実行使用メモリ 61,232 KB
最終ジャッジ日時 2024-04-10 10:07:05
合計ジャッジ時間 7,513 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
61,120 KB
testcase_01 AC 106 ms
52,764 KB
testcase_02 AC 128 ms
53,928 KB
testcase_03 AC 122 ms
54,124 KB
testcase_04 AC 137 ms
54,148 KB
testcase_05 AC 1,202 ms
54,012 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		System.out.println(calc(n,m));
	}

	static int calc(int n, int m){
		if(n == 2){
			return 1;
		}
		else if (n == 1) {
			return 0;
		}else{
			return (calc(n-1, m) + calc(n-2, m)) % m;
		}
	}
}
0