結果

問題 No.657 テトラナッチ数列 Easy
ユーザー htensaihtensai
提出日時 2019-11-13 09:09:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 296 ms / 2,000 ms
コード長 499 bytes
コンパイル時間 2,015 ms
コンパイル使用メモリ 75,224 KB
実行使用メモリ 65,744 KB
最終ジャッジ日時 2023-10-21 19:38:20
合計ジャッジ時間 6,433 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
61,536 KB
testcase_01 AC 147 ms
61,580 KB
testcase_02 AC 147 ms
61,672 KB
testcase_03 AC 149 ms
61,580 KB
testcase_04 AC 147 ms
61,588 KB
testcase_05 AC 256 ms
65,380 KB
testcase_06 AC 148 ms
61,440 KB
testcase_07 AC 149 ms
61,444 KB
testcase_08 AC 149 ms
61,480 KB
testcase_09 AC 277 ms
65,492 KB
testcase_10 AC 285 ms
65,236 KB
testcase_11 AC 287 ms
65,348 KB
testcase_12 AC 293 ms
65,308 KB
testcase_13 AC 296 ms
65,700 KB
testcase_14 AC 296 ms
65,460 KB
testcase_15 AC 295 ms
65,744 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[1000001];
		arr[4] = 1;
		for (int i = 5; i <= 1000000; 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++) {
		    sb.append(arr[sc.nextInt()]).append("\n");
		}
		System.out.print(sb);
  }
 }
0