結果
問題 | No.2600 Avator Height |
ユーザー | ks2m |
提出日時 | 2024-01-12 22:09:49 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 987 ms / 2,000 ms |
コード長 | 842 bytes |
コンパイル時間 | 4,718 ms |
コンパイル使用メモリ | 77,020 KB |
実行使用メモリ | 73,588 KB |
最終ジャッジ日時 | 2024-09-27 22:34:01 |
合計ジャッジ時間 | 27,575 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 |
ソースコード
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(); } }