結果

問題 No.657 テトラナッチ数列 Easy
ユーザー Tsukasa_Type
提出日時 2018-03-02 22:39:43
言語 Java
(openjdk 23)
結果
AC  
実行時間 354 ms / 2,000 ms
コード長 466 bytes
コンパイル時間 2,085 ms
コンパイル使用メモリ 74,372 KB
実行使用メモリ 63,264 KB
最終ジャッジ日時 2024-06-22 04:02:03
合計ジャッジ時間 6,614 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int[] ar = new int[1000000];
		ar[0] = 0;
		ar[1] = 0;
		ar[2] = 0;
		ar[3] = 1;
		ar[4] = ar[0]+ar[1]+ar[2]+ar[3];
		for (int i=5; i<=999999; i++) {
			ar[i] = (ar[i-1]+ar[i-2]+ar[i-3]+ar[i-4])%17;
		}
		
		int q = sc.nextInt();
		for (int i=0; i<q; i++) {
			out.println(ar[sc.nextInt()-1]);
		}
	}
}
0