QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#821775#9067. Rampant GrowthWeaRD276#AC ✓1ms3816kbC++201.5kb2024-12-19 18:03:082024-12-19 18:03:08

Judging History

你现在查看的是最新测评结果

  • [2024-12-19 18:03:08]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3816kb
  • [2024-12-19 18:03:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef double db;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;

const int MOD = 998244353;

ll add(ll a, ll b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

ll sub(ll a, ll b)
{
	return a - b < 0 ? a - b + MOD : a - b;
}

ll mult(ll a, ll b)
{
	return a * b % MOD;
}

int solve()
{
	int r, c;
	if (!(cin >> r >> c))
		return 1;
	
	vector dp(c, vector<ll>(r));
	FOR (i, 0, r)
		dp[0][i] = 1;
	FOR (i, 1, c)
	{
		FOR (j, 0, r)
		{
			ll smpr = 0;
			FOR (k, 0, r)
				smpr = add(smpr, dp[i - 1][k]);
			smpr = sub(smpr, dp[i - 1][j]);
			dp[i][j] = smpr;
		}
	}
	ll ans = 0;
	FOR (i, 0, r)
		ans = add(ans, dp[c - 1][i]);
	cout << ans << '\n';
	
	return 0;
}

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int TET = 1e9;
	//cin >> TET;
	for (int i = 1; i <= TET; i++)
	{
		if (solve())
		{
			break;
		}
		#ifdef ONPC
			cerr << "_____________________________\n";
		#endif
	}
	#ifdef ONPC
		cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
	#endif
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3544kb

input:

50 50

output:

347776301

result:

ok single line: '347776301'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

3 2

output:

6

result:

ok single line: '6'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3528kb

input:

1 5

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

42 25

output:

722210361

result:

ok single line: '722210361'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

1 1

output:

1

result:

ok single line: '1'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

1 50

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

50 1

output:

50

result:

ok single line: '50'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

2 50

output:

2

result:

ok single line: '2'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

12 41

output:

508608552

result:

ok single line: '508608552'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3784kb

input:

48 21

output:

873199164

result:

ok single line: '873199164'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

36 13

output:

339677219

result:

ok single line: '339677219'