結果
問題 | No.2413 Multiple of 99 |
ユーザー | chineristAC |
提出日時 | 2023-08-12 02:19:56 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,036 ms / 8,000 ms |
コード長 | 2,823 bytes |
コンパイル時間 | 5,800 ms |
コンパイル使用メモリ | 226,344 KB |
実行使用メモリ | 45,416 KB |
最終ジャッジ日時 | 2024-11-18 22:30:55 |
合計ジャッジ時間 | 18,824 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
26,964 KB |
testcase_01 | AC | 51 ms
26,960 KB |
testcase_02 | AC | 53 ms
26,952 KB |
testcase_03 | AC | 48 ms
27,076 KB |
testcase_04 | AC | 61 ms
27,220 KB |
testcase_05 | AC | 75 ms
27,204 KB |
testcase_06 | AC | 73 ms
27,248 KB |
testcase_07 | AC | 1,029 ms
45,352 KB |
testcase_08 | AC | 52 ms
26,964 KB |
testcase_09 | AC | 964 ms
45,348 KB |
testcase_10 | AC | 1,036 ms
45,348 KB |
testcase_11 | AC | 1,036 ms
45,352 KB |
testcase_12 | AC | 1,019 ms
45,416 KB |
testcase_13 | AC | 1,036 ms
45,224 KB |
testcase_14 | AC | 1,031 ms
45,352 KB |
testcase_15 | AC | 1,033 ms
45,352 KB |
testcase_16 | AC | 540 ms
36,252 KB |
testcase_17 | AC | 528 ms
35,692 KB |
testcase_18 | AC | 1,015 ms
44,524 KB |
testcase_19 | AC | 104 ms
27,968 KB |
testcase_20 | AC | 78 ms
27,244 KB |
testcase_21 | AC | 109 ms
27,852 KB |
testcase_22 | AC | 1,019 ms
44,508 KB |
testcase_23 | AC | 164 ms
28,984 KB |
ソースコード
#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; }