結果

問題 No.657 テトラナッチ数列 Easy
ユーザー Pump0129Pump0129
提出日時 2018-04-22 19:14:34
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,028 bytes
コンパイル時間 2,481 ms
コンパイル使用メモリ 75,096 KB
実行使用メモリ 78,864 KB
最終ジャッジ日時 2023-09-09 14:07:36
合計ジャッジ時間 8,584 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,496 KB
testcase_01 AC 44 ms
49,456 KB
testcase_02 AC 45 ms
49,480 KB
testcase_03 AC 44 ms
49,596 KB
testcase_04 AC 216 ms
77,468 KB
testcase_05 AC 121 ms
52,500 KB
testcase_06 AC 44 ms
49,440 KB
testcase_07 AC 45 ms
49,448 KB
testcase_08 AC 205 ms
78,864 KB
testcase_09 AC 130 ms
52,460 KB
testcase_10 AC 209 ms
53,236 KB
testcase_11 AC 215 ms
52,800 KB
testcase_12 AC 764 ms
64,084 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package net.ipipip0129.yukicoder.no657;

import java.io.*;
import java.util.LinkedList;

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;

        LinkedList<Integer> tet = new LinkedList<>();

        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