QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#314152#5448. 另一个欧拉数问题YeahPotato#20 11ms20436kbC++141.0kb2024-01-25 13:32:312024-07-04 03:21:35

Judging History

This is the latest submission verdict.

  • [2024-07-04 03:21:35]
  • Judged
  • Verdict: 20
  • Time: 11ms
  • Memory: 20436kb
  • [2024-01-25 13:32:31]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353, N = 2e5 + 5;
int a, n, m, n0, p[N], c, f[2005][2005], F[N], IF[N], ans;
int qpow(int x, int y) {
	int t = 1;
	for (; y; y>>=1) {
		if (y & 1) t = 1ll * t * x % MOD;
		x = 1ll * x * x % MOD;
	} return t;
}
int C(int n, int k) {
	return 1ll * F[n] * IF[k] % MOD * IF[n-k] % MOD;
}
int main() {
	cin >> a >> n >> m >> n0;
	if (a == 1 && n0 == 1) {
		for (int i=F[0]=1; i<=n+1; i++) F[i] = 1ll * F[i-1] * i % MOD;
		IF[n+1] = qpow(F[n+1], MOD - 2);
		for (int i=n; ~i; i--) IF[i] = 1ll * IF[i+1] * (i+1) % MOD;
		for (int i=1; i<=n-m; i++) ans = (ans + 1ll * (n - m - i & 1 ? MOD - qpow(i, n) : qpow(i, n)) * C(n + 1, m + i + 1)) % MOD;
		return cout << ans, 0;
	}
	for (int i=1; i<=a*n0; i++)
		scanf ("%d", &p[i]), c += i > 1 && p[i] < p[i-1];
	f[n0][c] = 1;
	for (int i=n0+1; i<=n; i++)
		for (int j=c; j<i; j++)
			f[i][j] = ((j ? 1ll * (a * (i - 1) - j + 1) * f[i-1][j-1] : 0) + 1ll * (j + 1) * f[i-1][j]) % MOD;
	cout << f[n][m];
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 7ms
memory: 20152kb

input:

584 1985 1017 186
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

683567838

result:

ok 1 number(s): "683567838"

Test #2:

score: 0
Accepted
time: 7ms
memory: 16164kb

input:

549 1352 215 144
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

514220824

result:

ok 1 number(s): "514220824"

Test #3:

score: 0
Accepted
time: 8ms
memory: 17904kb

input:

280 1833 1153 253
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ...

output:

801426026

result:

ok 1 number(s): "801426026"

Test #4:

score: 0
Accepted
time: 11ms
memory: 20216kb

input:

886 1885 1736 131
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...

output:

732050911

result:

ok 1 number(s): "732050911"

Test #5:

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

input:

464 1859 1766 385
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150...

output:

268474724

result:

ok 1 number(s): "268474724"

Test #6:

score: 0
Accepted
time: 3ms
memory: 13840kb

input:

468 1281 718 285
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

7958328

result:

ok 1 number(s): "7958328"

Test #7:

score: 0
Accepted
time: 7ms
memory: 20436kb

input:

973 1966 417 99
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 ...

output:

943626008

result:

ok 1 number(s): "943626008"

Test #8:

score: 0
Accepted
time: 4ms
memory: 16424kb

input:

224 1781 1724 358
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 ...

output:

550100613

result:

ok 1 number(s): "550100613"

Test #9:

score: 0
Accepted
time: 3ms
memory: 20028kb

input:

952 1793 939 19
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1...

output:

357850463

result:

ok 1 number(s): "357850463"

Test #10:

score: 0
Accepted
time: 9ms
memory: 17900kb

input:

978 1415 776 108
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

284767772

result:

ok 1 number(s): "284767772"

Subtask #2:

score: 10
Accepted

Test #11:

score: 10
Accepted
time: 9ms
memory: 6312kb

input:

1 199913 100055 1
1

output:

856065368

result:

ok 1 number(s): "856065368"

Test #12:

score: 0
Accepted
time: 6ms
memory: 6420kb

input:

1 197151 139288 1
1

output:

933745116

result:

ok 1 number(s): "933745116"

Test #13:

score: 0
Accepted
time: 3ms
memory: 6988kb

input:

1 198165 124475 1
1

output:

650379731

result:

ok 1 number(s): "650379731"

Test #14:

score: 0
Accepted
time: 4ms
memory: 5156kb

input:

1 199407 183908 1
1

output:

213038974

result:

ok 1 number(s): "213038974"

Test #15:

score: 0
Accepted
time: 11ms
memory: 5136kb

input:

1 195940 66608 1
1

output:

203000250

result:

ok 1 number(s): "203000250"

Subtask #3:

score: 0
Runtime Error

Dependency #2:

100%
Accepted

Test #16:

score: 0
Runtime Error

input:

1 199968 100029 81
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81

output:


result:


Subtask #4:

score: 0
Runtime Error

Test #21:

score: 0
Runtime Error

input:

2 199984 99989 1
1 1

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%