提出 #70682021


ソースコード 拡げる

N, U = map(int, input().split())

F = GF(998244353)
R.<y> = F[]
S.<x> = R[]

def Nth(n, u):
  fact = F(1)
  m = n
  while m > 1:
    fact *= m
    m -= 1
  Q = 1/F(2) * (1-y) * (-x^2*y - 6*x*y + 2*y^2 - 4*y + 2)
  P = fact * (-2*x*y + y^2 - 2*y + 1)
  while n > 0:
    nQ = Q(-x)
    P = S((P * nQ).list()[n%2::2])
    Q = S((Q * nQ).list()[::2])
    n //= 2
  return P(0).multiplication_trunc(Q(0).inverse_series_trunc(u+1), u+1)

ans = Nth(N, U).list()[1:]

for a in ans:
  print(a)

提出情報

提出日時
問題 U - 録画機
ユーザ ryuhei
言語 SageMath (SageMath 9.5)
得点 7
コード長 508 Byte
結果 AC
実行時間 2514 ms
メモリ 211620 KiB

ジャッジ結果

セット名 Sample Subtask All
得点 / 配点 0 / 0 4 / 4 3 / 3
結果
AC × 2
AC × 6
AC × 11
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt
Subtask 00_sample_00.txt, 00_sample_01.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 2514 ms 184744 KiB
00_sample_01.txt AC 824 ms 187920 KiB
01_small_00.txt AC 864 ms 191480 KiB
01_small_01.txt AC 875 ms 189284 KiB
01_small_02.txt AC 822 ms 188032 KiB
01_small_03.txt AC 886 ms 189872 KiB
02_random_00.txt AC 1333 ms 199320 KiB
02_random_01.txt AC 1614 ms 211620 KiB
02_random_02.txt AC 1713 ms 210248 KiB
02_random_03.txt AC 1392 ms 200112 KiB
02_random_04.txt AC 1753 ms 210340 KiB