結果

問題 No.1964 sum = length
ユーザー NanashimaNanashima
提出日時 2022-06-03 22:50:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,039 bytes
コンパイル時間 1,805 ms
コンパイル使用メモリ 175,312 KB
実行使用メモリ 325,164 KB
最終ジャッジ日時 2023-10-21 02:13:39
合計ジャッジ時間 20,362 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 3 ms
4,348 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,348 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define all(a)  (a).begin(),(a).end()
#define rall(a)  (a).rbegin(),(a).rend()
typedef long long ll;
typedef pair<ll,ll> pl;

const ll mod=998244353;

int main() {
    ll n;
    cin >> n;
    ll len=5*n;
    vector<vector<vector<ll>>> dp(n,vector<vector<ll>> (len,vector<ll> (n,0)));
    for(int i=1;i<len;i++) dp[0][i][i/10]=1;
    for(int i=0;i<n-1;i++) {
        rep(j,len) rep(k,n) { 
            for(int l=1;l<=1000;l*=10) {
                if(j+l<len&&k+l/10<n) dp[i+1][j+l][k+l/10]=(dp[i+1][j+l][k+l/10]+dp[i][j][k])%mod;
                if(j+l*10<len&&k+l/10<n) dp[i+1][j+l*10][k+l/10]=(dp[i+1][j+l*10][k+l/10]+(-dp[i][j][k]+2*mod)%mod)%mod;
            }
        }
        rep(j,n) for(int k=1;k<len;k++) dp[i+1][k][j]=(dp[i+1][k][j]+dp[i+1][k-1][j])%mod;
    }
    ll ans=0;
    for(int i=0;i<n;i++) {
        if(2*n-1+i<len) ans=(ans+dp[n-1][2*n-1+i][i])%mod;
    }
    cout << ans << endl;
    return 0;
}
0