結果

問題 No.657 テトラナッチ数列 Easy
ユーザー Pump0129Pump0129
提出日時 2018-04-22 19:04:37
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,012 bytes
コンパイル時間 3,479 ms
コンパイル使用メモリ 75,076 KB
実行使用メモリ 85,296 KB
最終ジャッジ日時 2023-09-09 14:06:25
合計ジャッジ時間 10,368 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,740 KB
testcase_01 AC 44 ms
49,420 KB
testcase_02 AC 44 ms
49,436 KB
testcase_03 AC 43 ms
49,360 KB
testcase_04 AC 186 ms
77,404 KB
testcase_05 AC 188 ms
54,352 KB
testcase_06 AC 44 ms
49,432 KB
testcase_07 AC 44 ms
49,356 KB
testcase_08 AC 188 ms
78,100 KB
testcase_09 AC 213 ms
53,192 KB
testcase_10 AC 300 ms
56,612 KB
testcase_11 AC 303 ms
55,012 KB
testcase_12 AC 899 ms
63,812 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package net.ipipip0129.yukicoder.no657;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;

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

        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;
            }

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

        br.close();
    }
}
0