結果

問題 No.658 テトラナッチ数列 Hard
ユーザー htensaihtensai
提出日時 2019-11-13 09:22:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 293 ms / 2,000 ms
コード長 581 bytes
コンパイル時間 2,168 ms
コンパイル使用メモリ 75,696 KB
実行使用メモリ 61,604 KB
最終ジャッジ日時 2023-10-21 19:39:11
合計ジャッジ時間 5,507 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
57,300 KB
testcase_01 AC 128 ms
57,012 KB
testcase_02 AC 126 ms
57,340 KB
testcase_03 AC 136 ms
57,220 KB
testcase_04 AC 277 ms
61,520 KB
testcase_05 AC 267 ms
61,560 KB
testcase_06 AC 277 ms
61,432 KB
testcase_07 AC 289 ms
61,436 KB
testcase_08 AC 292 ms
61,592 KB
testcase_09 AC 289 ms
61,588 KB
testcase_10 AC 293 ms
61,604 KB
権限があれば一括ダウンロードができます

ソースコード

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.print(sb);
  }
 }
0