QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#875756#10020. Heroes and Illusionsasdfsdf#WA 323ms4480kbC++23912b2025-01-30 12:16:522025-01-30 12:16:54

Judging History

This is the latest submission verdict.

  • [2025-01-30 12:16:54]
  • Judged
  • Verdict: WA
  • Time: 323ms
  • Memory: 4480kb
  • [2025-01-30 12:16:52]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define MOD 998244353
#define MAX 202020
ll mpow(ll x, ll y = MOD - 2) {
	ll mul = x;
	ll ans = 1;
	while (y) {
		if (y & 1) ans = (ans * mul) % MOD;
		y >>= 1;
		mul = (mul * mul) % MOD;
	}
	return ans;
}
ll fact[MAX];
void solve() {
	ll N, K;
	cin >> N >> K;
	ll i;
	ll ans = 0;
	for (i = 1; i <= K; i++) {
		if (K % i == 0) {
			ll e = i;
			ll o = K / i;
			if (o + e != N + 1) continue;
			e--;
			ll res = fact[N];
			res = (res * mpow(fact[e]));
			res %= MOD;
			res = (res * mpow(fact[N - e]));
			res %= MOD;
			ans += res;
			ans %= MOD;
		}
	}
	cout << ans << '\n';
}
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int T;
	cin >> T;
	int i;
	fact[0] = 1;
	for (i = 1; i <= 100'100; i++) fact[i] = (fact[i - 1] * i) % MOD;
	while (T--) solve();
}

详细

Test #1:

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

input:

1
5 9

output:

10

result:

ok 1 number(s): "10"

Test #2:

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

input:

4
3 4
6 12
6 11
12 30

output:

3
35
0
286

result:

ok 4 number(s): "3 35 0 286"

Test #3:

score: -100
Wrong Answer
time: 323ms
memory: 4352kb

input:

100000
1 0
1 1
2 0
2 1
2 2
2 3
3 0
3 1
3 2
3 3
3 4
3 5
3 6
4 0
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
5 0
5 1
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 10
5 11
5 12
5 13
5 14
5 15
6 0
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
6 10
6 11
6 12
6 13
6 14
6 15
6 16
6 17
6 18
6 19
6 20
6 21
7 0
7 1
7 2
7 3
7 4
7 5
7 ...

output:

0
1
0
0
3
0
0
0
0
4
3
0
0
0
0
0
0
5
0
10
0
0
0
0
0
0
0
0
0
6
0
0
15
10
0
0
0
0
0
0
0
0
0
0
0
0
7
0
0
0
21
0
35
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
8
0
0
0
0
28
0
0
56
35
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
9
0
0
0
0
0
36
0
0
0
84
0
126
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
10
0
0
0
0
0
0...

result:

wrong answer 1st numbers differ - expected: '1', found: '0'