結果

問題 No.2413 Multiple of 99
ユーザー milanis48663220milanis48663220
提出日時 2023-08-12 02:03:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,186 ms / 8,000 ms
コード長 2,393 bytes
コンパイル時間 2,381 ms
コンパイル使用メモリ 158,784 KB
実行使用メモリ 24,996 KB
最終ジャッジ日時 2024-04-29 16:45:08
合計ジャッジ時間 16,168 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 14 ms
5,376 KB
testcase_05 AC 32 ms
5,376 KB
testcase_06 AC 28 ms
5,376 KB
testcase_07 AC 1,172 ms
24,864 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1,098 ms
24,996 KB
testcase_10 AC 1,174 ms
24,932 KB
testcase_11 AC 1,186 ms
24,928 KB
testcase_12 AC 1,148 ms
24,872 KB
testcase_13 AC 1,164 ms
24,932 KB
testcase_14 AC 1,153 ms
24,804 KB
testcase_15 AC 1,163 ms
24,872 KB
testcase_16 AC 565 ms
14,484 KB
testcase_17 AC 560 ms
13,720 KB
testcase_18 AC 1,150 ms
24,164 KB
testcase_19 AC 65 ms
5,376 KB
testcase_20 AC 32 ms
5,376 KB
testcase_21 AC 64 ms
5,376 KB
testcase_22 AC 1,146 ms
24,048 KB
testcase_23 AC 137 ms
5,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#include <atcoder/modint>
#include <atcoder/convolution>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

using mint = atcoder::modint998244353;

ostream& operator<<(ostream& os, const mint& m){
    os << m.val();
    return os;
}

vector<mint> pow(vector<mint> v, int n){
    vector<mint> ans = {mint(1)};
    while (n > 0) {
        if (n&1) ans = atcoder::convolution(ans, v);
        v = atcoder::convolution(v, v);
        n >>= 1;
    }
    return ans;
}

int sum_digits(int n){
    int sum = 0;
    while(n){
        sum += n%10;
        n /= 10;
    }
    return sum;
}



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n, k; cin >> n >> k;
    vector<mint> x(10, mint(1));
    auto v = pow(x, n/2);
    auto u = pow(x, (n+1)/2);
    mint ans = 0;
    for(int r = 0; r < 11; r++){
        auto vv = v;
        auto uu = u;
        for(int i = 0; i < vv.size(); i++){
            if(i%11 != r) vv[i] = 0;
        }
        for(int i = 0; i < uu.size(); i++){
            if(i%11 != r) uu[i] = 0;
        }
        auto ww = atcoder::convolution(vv, uu);
        for(int i = 0; i < ww.size(); i++){
            if(i%9 == 0) ans += ww[i]*(mint(i).pow(k));
        }
    }
    cout << ans << endl;
}
0