Submission #4013949
Source Code Expand
MOD = 998244353
k, n = map(int, input().split())
list_size = 5000
f_list = [1] * list_size
f_r_list = [1] * list_size
for i in range(list_size - 1):
f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)
def power(n, x):
if x == 1:
return n
elif x % 2 == 0:
return power(int((n * n) % MOD), int(x / 2))
else:
return int((n * power(n, x - 1)) % MOD)
f_r_list[-1] = power(f_list[-1], MOD - 2)
for i in range(2, list_size + 1):
f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % MOD)
def comb(n, r):
if n < r or r < 0:
return 0
elif n == 0 or r == 0 or n == r:
return 1
else:
return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD
ans = []
for i in range(2, k+2):
num = 0
if i%2 == 1:
for j in range(0, i//2+1):
#num += comb(i//2, j) * comb(n-1, j-1) * pow(2, j, MOD) * comb(n+k-i-j, k-i)
num += comb(i//2, j) * pow(2, j, MOD) * comb(n+k-i, k-i+j)
num %= MOD
else:
for j in range(0, i//2):
#num += comb(i//2-1, j) * comb(n-1, j-1) * pow(2, j, MOD) * comb(n+k-i-j, k-i)
num += comb(i//2-1, j) * pow(2, j, MOD) * comb(n+k-i, k-i+j)
#num += comb(i//2-1, j) * comb(n-2, j-1) * pow(2, j, MOD) * comb(n+k-i-j-1, k-i)
num += comb(i//2-1, j) * pow(2, j, MOD) * comb(n+k-i-1, k-i+j)
num %= MOD
ans.append(num)
print(*ans, sep="\n")
ans = reversed(ans[:k-1])
print(*ans, sep="\n")
Submission Info
Submission Time |
|
Task |
E - Stop. Otherwise... |
User |
anagohirame |
Language |
PyPy3 (2.4.0) |
Score |
700 |
Code Size |
1409 Byte |
Status |
AC |
Exec Time |
959 ms |
Memory |
57836 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
700 / 700 |
Status |
|
|
Set Name |
Test Cases |
Sample |
s1.txt, s2.txt, s3.txt |
All |
01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, s1.txt, s2.txt, s3.txt |
Case Name |
Status |
Exec Time |
Memory |
01.txt |
AC |
959 ms |
55128 KB |
02.txt |
AC |
850 ms |
55344 KB |
03.txt |
AC |
953 ms |
55000 KB |
04.txt |
AC |
174 ms |
39024 KB |
05.txt |
AC |
741 ms |
50156 KB |
06.txt |
AC |
851 ms |
55000 KB |
07.txt |
AC |
953 ms |
55000 KB |
08.txt |
AC |
379 ms |
50904 KB |
09.txt |
AC |
169 ms |
39024 KB |
10.txt |
AC |
601 ms |
57836 KB |
11.txt |
AC |
688 ms |
51228 KB |
12.txt |
AC |
180 ms |
39024 KB |
13.txt |
AC |
365 ms |
50520 KB |
14.txt |
AC |
879 ms |
54872 KB |
15.txt |
AC |
899 ms |
55256 KB |
16.txt |
AC |
830 ms |
55128 KB |
17.txt |
AC |
168 ms |
39024 KB |
18.txt |
AC |
169 ms |
39024 KB |
19.txt |
AC |
171 ms |
39024 KB |
20.txt |
AC |
168 ms |
39024 KB |
s1.txt |
AC |
172 ms |
39024 KB |
s2.txt |
AC |
171 ms |
39024 KB |
s3.txt |
AC |
172 ms |
39892 KB |