結果

問題 No.2413 Multiple of 99
ユーザー chineristACchineristAC
提出日時 2023-08-12 02:19:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 962 ms / 8,000 ms
コード長 2,823 bytes
コンパイル時間 5,547 ms
コンパイル使用メモリ 224,728 KB
実行使用メモリ 45,420 KB
最終ジャッジ日時 2024-04-29 17:00:45
合計ジャッジ時間 17,135 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
26,880 KB
testcase_01 AC 44 ms
26,960 KB
testcase_02 AC 43 ms
26,880 KB
testcase_03 AC 42 ms
26,880 KB
testcase_04 AC 53 ms
27,136 KB
testcase_05 AC 71 ms
27,264 KB
testcase_06 AC 70 ms
27,200 KB
testcase_07 AC 941 ms
45,416 KB
testcase_08 AC 43 ms
26,880 KB
testcase_09 AC 869 ms
45,356 KB
testcase_10 AC 920 ms
45,416 KB
testcase_11 AC 919 ms
45,420 KB
testcase_12 AC 912 ms
45,352 KB
testcase_13 AC 962 ms
45,348 KB
testcase_14 AC 911 ms
45,356 KB
testcase_15 AC 935 ms
45,228 KB
testcase_16 AC 485 ms
36,128 KB
testcase_17 AC 474 ms
35,688 KB
testcase_18 AC 897 ms
44,268 KB
testcase_19 AC 87 ms
27,904 KB
testcase_20 AC 66 ms
27,372 KB
testcase_21 AC 89 ms
27,860 KB
testcase_22 AC 898 ms
44,640 KB
testcase_23 AC 138 ms
28,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
 
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <atcoder/all>

using namespace std;
using namespace atcoder;
typedef long long ll;

#define rep(i,n) for (int i=0;i<n;i+=1)
template<class T>
using vec = vector<T>;

#define all(x) (x).begin(), (x).end()

template<class T>
ostream& operator<<(ostream& os, const vector<T>& A){
  os << "[";
  rep(i,A.size()){
    os << A[i];
    if (i!=A.size()-1){
      os << ", ";
    }
  }
  os << "]" ;
  return os;
}

template<class T>
ostream& operator<<(ostream& os, const deque<T>& A){
  os << "deque{[";
  rep(i,A.size()){
    os << A[i];
    if (i!=A.size()-1){
      os << ", ";
    }
  }
  os << "]}" ;
  return os;
}

template<class T>
ostream& operator<<(ostream& os, const pair<T,T>& A){
  os << "(";
  os << A.first ;
  os << ", ";
  os << A.second;
  os << ")";
  return os;
}

using mint = modint998244353;

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

const int N = 2000000;
mint g1[N],g2[N],inverse[N];

void init_mint(){
    g1[1] = 1;
    g2[1] = 1;
    g1[0] = 1;
    g2[0] = 1;
    inverse[1] = 1;
    for (int n=2;n<N;n++){
        g1[n] = g1[n-1] * n;
        inverse[n] = (-inverse[998244353%n]) * (998244353/n);
        g2[n] = g2[n-1] * inverse[n];
    }
};

mint comb(int n,int r){
    if (r < 0 or n < r) return 0;
    return g1[n] * g2[r] * g2[n-r];
};


int main() {

  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  init_mint();

  int N,K;
  cin>>N>>K;

  int a = (N+1)/2,b = N/2;

  vec<mint> A(9*a+1,0);
  A[0] = 1;
  for (int n=1;n<=9*a;n++){
    for (int i=max(0,n-9);i<n;i++){
      A[n] += A[i] * (n-i);
    }
    A[n] *= a;
    for (int i=1;i<min(n,10);i++){
      A[n] -= A[n-i] * (n-i);
    }
    A[n] *= inverse[n];
  }

  vec<mint> B(9*b+1,0);
  B[0] = 1;
  for (int n=1;n<=9*b;n++){
    for (int i=max(0,n-9);i<n;i++){
      B[n] += B[i] * (n-i);
    }
    B[n] *= b;
    for (int i=1;i<min(n,10);i++){
      B[n] -= B[n-i] * (n-i);
    }
    B[n] *= inverse[n];
  }

  mint ans = 0;
  for (int r=0;r<11;r++){
    vec<mint> f(9*b+1),g(9*a+1);
    for (int t=r;t<=9*b;t+=11){
      f[t] = B[t];
    }
    for (int s=(9900-10*r)%11;s<=9*a;s+=11){
      g[s] = A[s];
    }
    vec<mint> h = convolution(f,g);
    rep(st,N+1){
      ans += h[st*9] * mint(st*9).pow(K);
    }

  }

  cout << ans << endl;




}
0