結果

問題 No.1964 sum = length
ユーザー hiro71687khiro71687k
提出日時 2023-03-07 08:33:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,342 bytes
コンパイル時間 4,788 ms
コンパイル使用メモリ 265,924 KB
実行使用メモリ 203,496 KB
最終ジャッジ日時 2023-10-18 05:23:45
合計ジャッジ時間 18,917 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,288 KB
testcase_01 AC 3 ms
5,496 KB
testcase_02 AC 46 ms
21,336 KB
testcase_03 AC 3 ms
5,496 KB
testcase_04 AC 5 ms
6,288 KB
testcase_05 AC 6 ms
7,344 KB
testcase_06 AC 8 ms
8,400 KB
testcase_07 AC 10 ms
9,456 KB
testcase_08 AC 13 ms
10,248 KB
testcase_09 AC 15 ms
11,304 KB
testcase_10 AC 17 ms
12,360 KB
testcase_11 AC 19 ms
13,416 KB
testcase_12 AC 154 ms
46,152 KB
testcase_13 AC 237 ms
65,160 KB
testcase_14 AC 317 ms
87,072 KB
testcase_15 AC 352 ms
97,896 KB
testcase_16 AC 43 ms
20,280 KB
testcase_17 AC 181 ms
52,224 KB
testcase_18 AC 204 ms
58,296 KB
testcase_19 AC 123 ms
39,288 KB
testcase_20 AC 136 ms
42,192 KB
testcase_21 AC 40 ms
19,224 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>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=int;
using ld=long double;
ld pie=3.14159265359;
ll inf=1001;
ll mod=998244353;
int main(){
	ll n;
	cin >> n;
	ll ans=0;
	vector<vector<vector<ll>>>dp(n,vector<vector<ll>>(500,vector<ll>(500,0)));
	for (ll i = 1; i < 10; i++)
	{
		dp[0][i][1]=1;
	}
	for (ll i = 10; i <100; i++)
	{
		dp[0][i][2]=1;
	}
	for (ll i = 100; i < n; i++)
	{
		dp[0][i][3]=1;
	}
	for (ll i = 1; i < n; i++)
	{
		for (ll j = 0; j < 500; j++)
		{
			for (ll k = 0; k < 500; k++)
			{
				if (dp[i-1][j][k]==0)
				{
					continue;
				}
				if (k+2>500)
				{
					continue;
				}
				for (ll l = 1; l < 10&&l+j<500; l++)
				{
					dp[i][j+l][k+2]+=dp[i-1][j][k];
					if (dp[i][j+l][k+2]>mod)
					{
						dp[i][j+l][k+2]-=mod;
					}
				}
				if (k+3>500)
				{
					continue;
				}
				for (ll l = 10; l < 100&&l+j<500; l++)
				{
					dp[i][j+l][k+3]+=dp[i-1][j][k];
					if (dp[i][j+l][k+3]>mod)
					{
						dp[i][j+l][k+3]-=mod;
					}
				}
				if (k+4>500)
				{
					continue;
				}
				for (ll l = 100; l < 500&&l+j<500; l++)
				{
					dp[i][j+l][k+4]+=dp[i-1][j][k];
					if (dp[i][j+l][k+4]>mod)
					{
						dp[i][j+l][k+4]-=mod;
					}
				}
			}
		}
	}
	for (ll i = 0; i < 500; i++)
	{
		ans+=dp[n-1][i][i];
		ans%=mod;
	}
	cout << ans << endl;
}
0