結果

問題 No.2413 Multiple of 99
ユーザー 👑 NachiaNachia
提出日時 2023-08-11 23:32:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 931 ms / 8,000 ms
コード長 1,751 bytes
コンパイル時間 2,382 ms
コンパイル使用メモリ 119,216 KB
実行使用メモリ 10,076 KB
最終ジャッジ日時 2024-04-29 14:43:59
合計ジャッジ時間 13,529 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 8 ms
5,376 KB
testcase_05 AC 24 ms
5,376 KB
testcase_06 AC 14 ms
5,376 KB
testcase_07 AC 931 ms
9,948 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 921 ms
10,076 KB
testcase_10 AC 930 ms
10,076 KB
testcase_11 AC 922 ms
9,944 KB
testcase_12 AC 923 ms
9,948 KB
testcase_13 AC 925 ms
9,948 KB
testcase_14 AC 921 ms
9,948 KB
testcase_15 AC 924 ms
10,076 KB
testcase_16 AC 436 ms
6,640 KB
testcase_17 AC 430 ms
6,504 KB
testcase_18 AC 916 ms
9,864 KB
testcase_19 AC 49 ms
5,376 KB
testcase_20 AC 24 ms
5,376 KB
testcase_21 AC 49 ms
5,376 KB
testcase_22 AC 920 ms
10,004 KB
testcase_23 AC 98 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <atcoder/modint>
#include <atcoder/convolution>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;

using Modint = atcoder::static_modint<998244353>;

void mul10(vector<Modint>& A){
    A.resize(A.size() + 9);
    rep(i,A.size()-1) A[i+1] += A[i];
    for(int i=A.size()-1; i>=10; i--) A[i] -= A[i-10];
}

vector<Modint> powdig(int N){
    if(N == 0){
        return vector<Modint>(1,1);
    }
    auto buf = powdig(N/2);
    auto A = atcoder::convolution(buf, buf);
    if(N%2 == 1) mul10(A);
    return A;
}

int main(){
    int N, K; cin >> N >> K;
    auto d1 = powdig(N/2);
    auto d0 = d1;
    if(N%2 == 1) mul10(d0);

    int Z = N + 1;
    vector<Modint> raizeK(Z+1); {
        vector<int> lpf(Z+1);
        raizeK[1] = 1;
        for(int p=2; p<=Z; p++){
            if(lpf[p]){ raizeK[p] = raizeK[lpf[p]] * raizeK[p/lpf[p]]; continue; }
            raizeK[p] = Modint(p).pow(K);
            for(int q=p*2; q<=Z; q+=p) lpf[q] = p;
        }
    }
    
    Modint ans = 0;
    rep(c0,99){
        vector<Modint> A(N/2+2);
        for(int c=c0; c<(int)d0.size(); c+=99) A[c/9] = d0[c];
        vector<Modint> B(N/2+2);
        rep(i,d1.size()) if((i*10+c0)%99 == 0) B[(i+8)/9] = d1[i];
        A = atcoder::convolution(A, B);
        rep(i,A.size()) ans += A[i] * raizeK[i];
    }
    ans *= Modint(9).pow(K);
    cout << ans.val() << endl;
    return 0;
}


struct ios_do_not_sync{
    ios_do_not_sync(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} ios_do_not_sync_instance;

0