結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,808 KB
testcase_01 AC 45 ms
49,388 KB
testcase_02 AC 45 ms
49,512 KB
testcase_03 AC 43 ms
49,368 KB
testcase_04 AC 176 ms
77,164 KB
testcase_05 AC 109 ms
52,744 KB
testcase_06 AC 43 ms
49,384 KB
testcase_07 AC 42 ms
49,580 KB
testcase_08 AC 189 ms
76,484 KB
testcase_09 AC 111 ms
52,608 KB
testcase_10 AC 193 ms
52,812 KB
testcase_11 AC 205 ms
52,960 KB
testcase_12 AC 738 ms
63,112 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));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(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;
            }

            bw.write(tet.get(n - 1).toString());
            bw.newLine();
        }

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