結果

問題 No.129 お年玉(2)
ユーザー maspymaspy
提出日時 2020-02-24 20:27:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,258 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 44,744 KB
最終ジャッジ日時 2024-04-20 15:19:30
合計ジャッジ時間 26,117 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 511 ms
43,984 KB
testcase_02 AC 505 ms
44,120 KB
testcase_03 AC 457 ms
43,988 KB
testcase_04 AC 460 ms
44,240 KB
testcase_05 AC 470 ms
44,368 KB
testcase_06 AC 475 ms
43,992 KB
testcase_07 AC 474 ms
44,368 KB
testcase_08 AC 463 ms
44,376 KB
testcase_09 AC 464 ms
44,112 KB
testcase_10 AC 466 ms
44,488 KB
testcase_11 WA -
testcase_12 AC 462 ms
43,992 KB
testcase_13 AC 466 ms
44,364 KB
testcase_14 AC 474 ms
44,628 KB
testcase_15 AC 477 ms
44,240 KB
testcase_16 AC 477 ms
44,628 KB
testcase_17 AC 469 ms
44,496 KB
testcase_18 WA -
testcase_19 AC 495 ms
44,236 KB
testcase_20 AC 463 ms
44,628 KB
testcase_21 AC 471 ms
43,980 KB
testcase_22 WA -
testcase_23 AC 465 ms
44,492 KB
testcase_24 AC 463 ms
43,988 KB
testcase_25 WA -
testcase_26 AC 480 ms
43,992 KB
testcase_27 AC 474 ms
44,372 KB
testcase_28 AC 474 ms
43,988 KB
testcase_29 AC 487 ms
43,728 KB
testcase_30 AC 453 ms
44,492 KB
testcase_31 AC 458 ms
44,272 KB
testcase_32 AC 456 ms
44,368 KB
testcase_33 AC 468 ms
44,364 KB
testcase_34 AC 462 ms
44,496 KB
testcase_35 AC 472 ms
44,240 KB
testcase_36 AC 462 ms
44,500 KB
testcase_37 AC 474 ms
44,112 KB
testcase_38 AC 467 ms
44,364 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 472 ms
44,236 KB
testcase_42 AC 456 ms
43,980 KB
testcase_43 AC 460 ms
44,248 KB
testcase_44 AC 468 ms
44,744 KB
testcase_45 AC 455 ms
44,020 KB
testcase_46 AC 459 ms
44,372 KB
testcase_47 WA -
testcase_48 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


# %%
import numpy as np


# %%
N, M = map(int, read().split())
N, M

# %%
MOD = 10 ** 9


# %%
def fft_convolve(f, g, MOD=MOD):
    """
    数列 (多項式) f, g の畳み込みの計算.上下 15 bitずつ分けて計算することで,
    30 bit以下の整数,長さ 250000 程度の数列での計算が正確に行える.
    """
    fft = np.fft.rfft
    ifft = np.fft.irfft
    Lf = len(f)
    Lg = len(g)
    L = Lf + Lg - 1
    fft_len = 1 << L.bit_length()
    fl = f & (1 << 15) - 1
    fh = f >> 15
    gl = g & (1 << 15) - 1
    gh = g >> 15

    def conv(f, g):
        return ifft(fft(f, fft_len) * fft(g, fft_len))[:L]
    x = conv(fl, gl) % MOD
    y = conv(fl + fh, gl + gh) % MOD
    z = conv(fh, gh) % MOD
    a, b, c = map(lambda x: (x + .5).astype(np.int64), [x, y, z])
    return (a + ((b - a - c) << 15) + (c << 30)) % MOD


# %%
def make_comb(n):
    if n == 0:
        return np.int64([1])
    P = make_comb(n // 2)
    P = fft_convolve(P, P)
    if n & 1:
        P = np.convolve(P, np.int64([1, 1]))
    return P


# %%
answer = make_comb(M)[(N // 1000) % M]
print(answer)
0