結果

問題 No.314 ケンケンパ
ユーザー mikhail
提出日時 2019-12-05 11:31:58
言語 Java
(openjdk 23)
結果
MLE  
実行時間 -
コード長 633 bytes
コンパイル時間 1,886 ms
コンパイル使用メモリ 74,572 KB
実行使用メモリ 856,612 KB
最終ジャッジ日時 2024-12-17 16:31:02
合計ジャッジ時間 11,504 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 TLE * 1 MLE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.math.BigInteger;

public class Main{
	
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		// input
		final int NUM = scan.nextInt();
		BigInteger[] kenpa = new BigInteger[NUM+1];
		
		// search
		for(int i = 1; i <= NUM; i++){
			if(i == 1){
				kenpa[1] = BigInteger.valueOf(1);
			} else if(i == 2){
				kenpa[2] = BigInteger.valueOf(2);
			} else if(i == 3){
				kenpa[3] = BigInteger.valueOf(2);
			} else {
				kenpa[i] = kenpa[i-2].add(kenpa[i-3]);
			}
		}
		
		// answer
		System.out.println(kenpa[NUM].mod(BigInteger.valueOf(1000000007)));
		
		
	}
}
0