結果

問題 No.2413 Multiple of 99
ユーザー chineristACchineristAC
提出日時 2023-08-12 02:07:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,822 bytes
コンパイル時間 5,631 ms
コンパイル使用メモリ 224,664 KB
実行使用メモリ 24,456 KB
最終ジャッジ日時 2024-04-29 16:49:11
合計ジャッジ時間 17,932 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
5,760 KB
testcase_01 AC 6 ms
5,760 KB
testcase_02 AC 6 ms
5,888 KB
testcase_03 AC 6 ms
5,888 KB
testcase_04 AC 17 ms
6,016 KB
testcase_05 AC 31 ms
6,144 KB
testcase_06 AC 29 ms
6,240 KB
testcase_07 WA -
testcase_08 AC 7 ms
5,760 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 59 ms
6,912 KB
testcase_20 AC 32 ms
6,280 KB
testcase_21 AC 59 ms
6,784 KB
testcase_22 WA -
testcase_23 AC 117 ms
7,752 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 = 200000;
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