結果
| 問題 |
No.2904 Distinct Multisets in a Way
|
| コンテスト | |
| ユーザー |
ニックネーム
|
| 提出日時 | 2024-09-27 23:11:43 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 1,306 ms / 2,000 ms |
| コード長 | 271 bytes |
| コンパイル時間 | 459 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 50,048 KB |
| 最終ジャッジ日時 | 2024-09-27 23:12:00 |
| 合計ジャッジ時間 | 15,974 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 42 |
ソースコード
n,z = int(input()),998244353
if n==0: exit(print(0))
# a: https://oeis.org/A002426
# b: https://oeis.org/A027914
a = [1]; b = [1,0]
for i in range(n):
a.append((3*a[i]-2*b[i+1])%z)
b.append((i+1)*(2*b[i+1]+3*b[i])%z*pow(i+3,-1,z)%z)
print((a[-2]-1)*pow(2,-1,z)%z)
ニックネーム