結果

問題 No.657 テトラナッチ数列 Easy
ユーザー YamaKasaYamaKasa
提出日時 2018-10-01 13:10:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 255 ms / 2,000 ms
コード長 567 bytes
コンパイル時間 3,471 ms
コンパイル使用メモリ 75,224 KB
実行使用メモリ 51,392 KB
最終ジャッジ日時 2024-04-20 14:08:48
合計ジャッジ時間 7,153 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
45,644 KB
testcase_01 AC 121 ms
45,200 KB
testcase_02 AC 119 ms
45,408 KB
testcase_03 AC 126 ms
45,268 KB
testcase_04 AC 113 ms
45,416 KB
testcase_05 AC 228 ms
50,452 KB
testcase_06 AC 113 ms
44,368 KB
testcase_07 AC 126 ms
45,496 KB
testcase_08 AC 131 ms
45,184 KB
testcase_09 AC 232 ms
51,044 KB
testcase_10 AC 255 ms
50,684 KB
testcase_11 AC 236 ms
51,088 KB
testcase_12 AC 250 ms
51,212 KB
testcase_13 AC 249 ms
51,392 KB
testcase_14 AC 246 ms
51,324 KB
testcase_15 AC 241 ms
51,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int Q = scan.nextInt();
		int max = (int)Math.pow(10, 6) + 1;
		int[]T = new int[max];
		T[0] = 0;
		T[1] = 0;
		T[2] = 0;
		T[3] = 1;
		for(int i = 4; i < max; i++) {
			T[i] = (T[i - 1] + T[i - 2] + T[i - 3] + T[i - 4]) % 17;
		}
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < Q; i++) {
			int n = scan.nextInt();
			sb.append(T[n - 1]);
			sb.append("\n");
		}
		scan.close();
		System.out.print(sb.toString());
	}
}
0