結果

問題 No.2600 Avator Height
ユーザー tentententen
提出日時 2024-01-15 10:28:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 454 ms / 2,000 ms
コード長 2,109 bytes
コンパイル時間 2,807 ms
コンパイル使用メモリ 91,420 KB
実行使用メモリ 65,712 KB
最終ジャッジ日時 2024-01-15 10:28:58
合計ジャッジ時間 16,499 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
55,484 KB
testcase_01 AC 386 ms
65,632 KB
testcase_02 AC 370 ms
65,548 KB
testcase_03 AC 392 ms
65,448 KB
testcase_04 AC 353 ms
65,700 KB
testcase_05 AC 448 ms
65,444 KB
testcase_06 AC 374 ms
65,364 KB
testcase_07 AC 445 ms
65,428 KB
testcase_08 AC 342 ms
65,512 KB
testcase_09 AC 382 ms
61,608 KB
testcase_10 AC 366 ms
65,444 KB
testcase_11 AC 454 ms
65,436 KB
testcase_12 AC 342 ms
63,448 KB
testcase_13 AC 351 ms
65,176 KB
testcase_14 AC 360 ms
65,532 KB
testcase_15 AC 356 ms
65,712 KB
testcase_16 AC 377 ms
65,548 KB
testcase_17 AC 358 ms
65,552 KB
testcase_18 AC 361 ms
65,676 KB
testcase_19 AC 355 ms
65,484 KB
testcase_20 AC 377 ms
65,512 KB
testcase_21 AC 363 ms
65,520 KB
testcase_22 AC 359 ms
65,440 KB
testcase_23 AC 382 ms
65,300 KB
testcase_24 AC 322 ms
62,712 KB
testcase_25 AC 355 ms
65,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    static final int MOD = 998244353;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int q = sc.nextInt();
        long r1 = 1;
        long r2 = 1;
        long e1 = 1;
        long e2 = 3;
        long[] ans = new long[200001];
        ans[1] = 4;
        ans[2] = MOD - 4;
        for (int i = 3; i < ans.length; i++) {
            long r = (r1 + r2) % MOD;
            long e = (e1 + e2) % MOD;
            ans[i] = (5 * r % MOD * r % MOD - (e * e % MOD) + MOD) % MOD;
            r1 = r2;
            r2 = r;
            e1 = e2;
            e2 = e;
        }
        StringBuilder sb = new StringBuilder();
        while (q-- > 0) {
            sb.append(ans[sc.nextInt()]).append("\n");
        }
        System.out.print(sb);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0