結果

問題 No.657 テトラナッチ数列 Easy
ユーザー Pump0129Pump0129
提出日時 2018-04-22 19:18:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 1,150 bytes
コンパイル時間 2,002 ms
コンパイル使用メモリ 74,228 KB
実行使用メモリ 62,148 KB
最終ジャッジ日時 2023-09-09 14:07:44
合計ジャッジ時間 4,543 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,352 KB
testcase_01 AC 43 ms
49,348 KB
testcase_02 AC 43 ms
49,364 KB
testcase_03 AC 42 ms
49,232 KB
testcase_04 AC 101 ms
60,856 KB
testcase_05 AC 119 ms
52,896 KB
testcase_06 AC 42 ms
49,200 KB
testcase_07 AC 43 ms
49,156 KB
testcase_08 AC 111 ms
61,608 KB
testcase_09 AC 122 ms
52,320 KB
testcase_10 AC 124 ms
52,380 KB
testcase_11 AC 127 ms
52,208 KB
testcase_12 AC 149 ms
57,352 KB
testcase_13 AC 197 ms
62,076 KB
testcase_14 AC 187 ms
62,000 KB
testcase_15 AC 194 ms
62,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package net.ipipip0129.yukicoder.no657;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        int count = Integer.parseInt(br.readLine());
        int maxSize = 4;

        List<Integer> tet = new ArrayList<>();

        tet.add(0);
        tet.add(0);
        tet.add(0);
        tet.add(1);

        for (int c = 0; c < count; c++) {
            int n = Integer.parseInt(br.readLine());
            if (maxSize < n) {
                for (int i = maxSize; i < n; i++) {
                    tet.add((tet.get(i - 1) + tet.get(i - 2) + tet.get(i - 3) + tet.get(i - 4)) % 17);
                }
                maxSize = n;
            }

            out.println(tet.get(n - 1));
        }

        out.flush();
        out.close();
        br.close();
    }
}
0