結果

問題 No.658 テトラナッチ数列 Hard
ユーザー htensaihtensai
提出日時 2019-11-13 09:21:51
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 583 bytes
コンパイル時間 2,369 ms
コンパイル使用メモリ 83,280 KB
実行使用メモリ 62,044 KB
最終ジャッジ日時 2023-10-21 19:38:49
合計ジャッジ時間 5,708 ms
ジャッジサーバーID
(参考情報)
judge10 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 17;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		int[] arr = new int[5001];
		arr[4] = 1;
		TreeSet<Integer> set = new TreeSet<>();
		for (int i = 5; i <= 5000; i++) {
		    arr[i] = (arr[i - 1] + arr[i - 2] + arr[i - 3] + arr[i - 4]) % MOD;
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
		    int idx = (int)((sc.nextLong() - 1) % 4912 + 1);
		    sb.append(arr[idx]).append("\n");
		}
		System.out.println(sb);
  }
 }
0