結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
57,588 KB
testcase_01 AC 130 ms
57,220 KB
testcase_02 AC 132 ms
57,552 KB
testcase_03 AC 131 ms
57,188 KB
testcase_04 AC 131 ms
57,200 KB
testcase_05 AC 249 ms
61,292 KB
testcase_06 AC 129 ms
57,704 KB
testcase_07 AC 131 ms
57,408 KB
testcase_08 AC 135 ms
57,460 KB
testcase_09 AC 261 ms
61,200 KB
testcase_10 AC 274 ms
61,200 KB
testcase_11 AC 277 ms
61,236 KB
testcase_12 AC 280 ms
61,448 KB
testcase_13 AC 284 ms
61,356 KB
testcase_14 AC 280 ms
61,116 KB
testcase_15 AC 277 ms
61,760 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