結果

問題 No.2600 Avator Height
ユーザー ks2mks2m
提出日時 2024-01-12 22:09:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 986 ms / 2,000 ms
コード長 842 bytes
コンパイル時間 2,000 ms
コンパイル使用メモリ 77,580 KB
実行使用メモリ 79,032 KB
最終ジャッジ日時 2024-01-12 22:10:21
合計ジャッジ時間 28,088 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 152 ms
60,620 KB
testcase_01 AC 948 ms
78,700 KB
testcase_02 AC 922 ms
76,988 KB
testcase_03 AC 978 ms
78,376 KB
testcase_04 AC 907 ms
76,644 KB
testcase_05 AC 971 ms
78,672 KB
testcase_06 AC 903 ms
77,260 KB
testcase_07 AC 958 ms
78,248 KB
testcase_08 AC 926 ms
78,692 KB
testcase_09 AC 985 ms
77,628 KB
testcase_10 AC 947 ms
78,424 KB
testcase_11 AC 958 ms
78,364 KB
testcase_12 AC 909 ms
76,492 KB
testcase_13 AC 948 ms
78,416 KB
testcase_14 AC 923 ms
78,280 KB
testcase_15 AC 986 ms
78,400 KB
testcase_16 AC 910 ms
76,316 KB
testcase_17 AC 960 ms
76,484 KB
testcase_18 AC 939 ms
78,744 KB
testcase_19 AC 929 ms
75,984 KB
testcase_20 AC 940 ms
78,780 KB
testcase_21 AC 935 ms
78,356 KB
testcase_22 AC 924 ms
77,096 KB
testcase_23 AC 957 ms
76,744 KB
testcase_24 AC 783 ms
79,032 KB
testcase_25 AC 954 ms
77,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		int[] n = new int[q];
		for (int i = 0; i < q; i++) {
			n[i] = sc.nextInt();
		}
		sc.close();

		int m = 200001;
		int mod = 998244353;
		long[] r = new long[m];
		r[1] = 1;
		r[2] = 1;
		long[] e = new long[m];
		e[1] = 1;
		e[2] = 3;
		for (int i = 3; i < m; i++) {
			r[i] = (r[i - 2] + r[i - 1]) % mod;
			e[i] = (e[i - 2] + e[i - 1]) % mod;
		}

		long[] ans = new long[m];
		for (int i = 1; i < m; i++) {
			ans[i] = (5 * r[i] * r[i] - e[i] * e[i]) % mod;
			if (ans[i] < 0) {
				ans[i] += mod;
			}
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; i++) {
			pw.println(ans[n[i]]);
		}
		pw.flush();
	}
}
0