結果

問題 No.2883 K-powered Sum of Fibonacci
ユーザー sortA0329sortA0329
提出日時 2024-08-02 15:53:16
言語 C++23(gcc13)
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 826 bytes
コンパイル時間 512 ms
コンパイル使用メモリ 35,980 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-08-02 15:53:18
合計ジャッジ時間 1,909 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
6,940 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 2 ms
6,944 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 AC 2 ms
6,944 KB
testcase_41 AC 2 ms
6,944 KB
testcase_42 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
int main() {
    long long N;
    int K;
    std::scanf("%lld%d", &N, &K);
    constexpr int limit = 40000000;
    if(N > limit) return 12;
    static unsigned F[limit], R[limit];
    F[0] = F[1] = 1;
    for(int i = 2; i < N; ++i) {
        F[i] = F[i - 1] + F[i - 2];
    }
    for(int i = 0; i != N; ++i) R[i] = 1;
    while(K != 0) {
        if(K & 1) {
            for(int i = 0; i != N; ++i) {
                R[i] = (unsigned long long) R[i] * F[i] % 998244353;
            }
        }
        for(int i = 0; i != N; ++i) {
            F[i] = (unsigned long long) F[i] * F[i] % 998244353;
        }
        K >>= 1;
    }
    unsigned res = 0;
    for(int i = 0; i != N; ++i) res = (res + R[i]) % 998244353;
    printf("%u\n", res);
}
0