結果

問題 No.657 テトラナッチ数列 Easy
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-03-02 22:39:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 381 ms / 2,000 ms
コード長 466 bytes
コンパイル時間 2,263 ms
コンパイル使用メモリ 72,264 KB
実行使用メモリ 64,820 KB
最終ジャッジ日時 2023-09-04 04:30:14
合計ジャッジ時間 7,462 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
59,656 KB
testcase_01 AC 137 ms
60,088 KB
testcase_02 AC 137 ms
59,592 KB
testcase_03 AC 139 ms
59,912 KB
testcase_04 AC 136 ms
60,076 KB
testcase_05 AC 344 ms
61,460 KB
testcase_06 AC 138 ms
57,872 KB
testcase_07 AC 139 ms
59,920 KB
testcase_08 AC 137 ms
59,592 KB
testcase_09 AC 359 ms
64,180 KB
testcase_10 AC 375 ms
64,544 KB
testcase_11 AC 373 ms
64,340 KB
testcase_12 AC 381 ms
64,784 KB
testcase_13 AC 362 ms
64,620 KB
testcase_14 AC 362 ms
64,596 KB
testcase_15 AC 378 ms
64,820 KB
権限があれば一括ダウンロードができます

ソースコード

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