QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#441823#8171. ColaHKOI0#WA 162ms471308kbC++141.2kb2024-06-14 19:17:322024-06-14 19:17:33

Judging History

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

  • [2024-06-14 19:17:33]
  • 评测
  • 测评结果:WA
  • 用时:162ms
  • 内存:471308kb
  • [2024-06-14 19:17:32]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define all(a) begin(a), end(a)
using namespace std;

const int MOD = 998244353;

int pm(int a, int b){
	return b == 0 ? 1 : pm(a * a % MOD, b / 2) * (b % 2 ? a : 1) % MOD;
}
int mi(int a){
	return pm(a, MOD - 2);
}

const int N = 2e7 + 11;
// pentagonal thm
int a[N];
int fa[N], fi[N];
int binom(int n, int r){
	return fa[n] * fi[n - r] % MOD * fi[r] % MOD;
}
void solve() {
	int n, m; cin >> n >> m; --m;
	a[0] = 1;
	for (int k = 1; (3 * k * k - k) / 2 < N; k++) {
		int b1 = (k * k * 3 + k) / 2;
		int b2 = (k * k * 3 - k) / 2;
		if (b1 < N) a[b1] = k % 2 ? -1 : 1;
		if (b2 < N) a[b2] = k % 2 ? -1 : 1;
	}
	for (int i = 0; i <= 10; i++) {
		cout << a[i] << ' ';
	}
	cout << endl;
	fa[0] = 1; for (int i = 1; i < N; i++) fa[i] = fa[i - 1] * i % MOD;
	fi[N - 1] = mi(fa[N - 1]); for (int i = N - 2; i >= 0; i--) fi[i] = fi[i + 1] * (i + 1) % MOD;
	int ans = 0;
	for (int k = 0; k <= m; k++) {
		ans += binom(k + n, n) * a[m - k] % MOD;
		ans %= MOD;
	}
	ans = (ans % MOD + MOD) % MOD;
	ans = ans * fi[n] % MOD;
	cout << ans << '\n';
}

int32_t main(){
#ifndef LOCAL
	cin.tie(0)->sync_with_stdio(false);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}

详细

Test #1:

score: 0
Wrong Answer
time: 162ms
memory: 471308kb

input:

2 1

output:

1 -1 -1 0 0 1 0 1 0 0 0 
499122177

result:

wrong answer 1st words differ - expected: '499122177', found: '1'