結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー aaaaasatori
提出日時 2018-02-13 21:54:02
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 388 bytes
コンパイル時間 3,263 ms
コンパイル使用メモリ 74,804 KB
実行使用メモリ 219,744 KB
最終ジャッジ日時 2024-12-14 04:42:40
合計ジャッジ時間 32,743 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 TLE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No526 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		System.out.println(fibonacci(N) % M);
	}
	
	public static int fibonacci(int N) {
		if(N == 1) {
			return 0;
		}else if(N == 2) {
			return 1;
		}else {
			return fibonacci(N -1) + fibonacci(N -2);
		}
	}
}
0