結果
問題 | No.2302 Carry X Times |
ユーザー |
![]() |
提出日時 | 2023-05-12 21:43:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 1,151 bytes |
コンパイル時間 | 3,781 ms |
コンパイル使用メモリ | 264,104 KB |
最終ジャッジ日時 | 2025-02-12 22:23:15 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 24 |
ソースコード
#include <stdio.h>#include <atcoder/all>#include <bits/stdc++.h>using namespace std;using namespace atcoder;using mint = modint998244353;#define rep(i,n) for (int i = 0; i < (n); ++i)#define Inf32 1000000001#define Inf64 4000000000000000001int main(){int _t;cin>>_t;rep(_,_t){long long n,x;cin>>n>>x;string s = to_string(n);reverse(s.begin(),s.end());s.push_back('0');vector dp(2,vector(2,vector(2,vector<mint>(x+1))));dp[0][0][0][0] = 1;rep(i,s.size()){int xx = s[i]-'0';vector ndp(2,vector(2,vector(2,vector<mint>(x+1))));rep(j,2){rep(k,2){rep(m,2){rep(l,x+1){if(dp[j][k][m][l]==0)continue;rep(a,10){rep(b,10){int jj = j,kk = k;if(a<xx)jj = 0;if(a>xx)jj = 1;if(b<xx)kk = 0;if(b>xx)kk = 1;int ll = l;int mm = 0;if(m+a+b>=10){ll++;mm = 1;}if(ll>x)continue;ndp[jj][kk][mm][ll] += dp[j][k][m][l];}}}}}}swap(dp,ndp);}cout<<dp[0][0][0][x].val()<<endl;}return 0;}