結果

問題 No.657 テトラナッチ数列 Easy
ユーザー silviasetitechsilviasetitech
提出日時 2020-03-05 21:56:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 317 ms / 2,000 ms
コード長 1,131 bytes
コンパイル時間 2,528 ms
コンパイル使用メモリ 76,632 KB
実行使用メモリ 51,240 KB
最終ジャッジ日時 2024-04-22 03:18:25
合計ジャッジ時間 6,726 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
45,260 KB
testcase_01 AC 149 ms
44,812 KB
testcase_02 AC 150 ms
45,592 KB
testcase_03 AC 147 ms
45,176 KB
testcase_04 AC 149 ms
45,152 KB
testcase_05 AC 286 ms
50,796 KB
testcase_06 AC 135 ms
43,984 KB
testcase_07 AC 138 ms
44,172 KB
testcase_08 AC 150 ms
45,236 KB
testcase_09 AC 305 ms
50,988 KB
testcase_10 AC 305 ms
50,124 KB
testcase_11 AC 305 ms
51,152 KB
testcase_12 AC 315 ms
51,240 KB
testcase_13 AC 317 ms
50,624 KB
testcase_14 AC 317 ms
51,156 KB
testcase_15 AC 312 ms
50,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Tetranacci solver = new Tetranacci();
        solver.solve(1, in, out);
        out.close();
    }

    static class Tetranacci {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int q = in.nextInt();
            int[] t = new int[1000005];
            t[1] = 0;
            t[2] = 0;
            t[3] = 0;
            t[4] = 1;
            for (int i = 5; i <= 1000000; i++) {
                t[i] = (t[i - 1] + t[i - 2] + t[i - 3] + t[i - 4]) % 17;
            }

            for (int i = 0; i < q; i++) {
                out.println(t[in.nextInt()]);
            }


        }

    }
}

0