QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#73300#4812. Counting SequenceLG_MonkeyRE 0ms0kbC++141.1kb2023-01-23 16:49:282023-01-23 16:49:30

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-23 16:49:30]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-01-23 16:49:28]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define pb push_back
#define se second
#define ll long long
int n, c, f[300010][1210]; int** g;
const int mod = 998244353;
signed main() {
	cin >> n >> c;
	int len = 800;
	for (int i = 1; i <= len; i++) f[i][i] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= min(1200, i); j++) {
			if (i == j) continue;
			f[i][j] += (ll)f[i - j][j + 1] * (ll)c % (ll)mod;
			if (j >= 2) f[i][j] = ((ll)f[i][j] + (ll)f[i - j][j - 1]) % (ll)mod;
		}
	ll ans = 0;
	for (int i = 1; i <= 1200; i++) (ans += f[n][i]) %= mod;
	delete[] f;
	g = new int *;
	for (int i = 1; i <= 800; i++)
		for (int j = 0; j <= 600000; j++) {
			int k = j - 300000;
			if (i == 0 && k == 0) {
				g[i][j] = 1; continue; 
			}
			if (j - i + 1 >= 0) g[i][j] += g[i - 1][j - i + 1];
			if (j + i - 1 <= 600000) g[i][j] += g[i - 1][j + i - 1] * c; g[i][j] %= mod;
		}
	for (int i = len + 1; i <= n; i++)
		for (int j = 1; j <= 2005; j++)
			(ans += g[j][n - i * j]) %= mod;
	cout << ans << "\n";
	return 0;
} 

详细

Test #1:

score: 0
Dangerous Syscalls

input:

5 3

output:


result: