結果

問題 No.1532 Different Products
ユーザー chineristACchineristAC
提出日時 2021-05-02 03:47:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,415 ms / 4,000 ms
コード長 1,967 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 82,352 KB
実行使用メモリ 258,048 KB
最終ジャッジ日時 2024-10-10 04:49:41
合計ジャッジ時間 52,343 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
56,636 KB
testcase_01 AC 290 ms
144,184 KB
testcase_02 AC 48 ms
62,612 KB
testcase_03 AC 44 ms
56,664 KB
testcase_04 AC 44 ms
56,644 KB
testcase_05 AC 46 ms
56,920 KB
testcase_06 AC 60 ms
68,892 KB
testcase_07 AC 64 ms
69,696 KB
testcase_08 AC 68 ms
72,444 KB
testcase_09 AC 170 ms
107,180 KB
testcase_10 AC 365 ms
171,536 KB
testcase_11 AC 302 ms
152,172 KB
testcase_12 AC 756 ms
256,388 KB
testcase_13 AC 533 ms
232,828 KB
testcase_14 AC 1,208 ms
256,964 KB
testcase_15 AC 165 ms
107,192 KB
testcase_16 AC 318 ms
155,768 KB
testcase_17 AC 344 ms
167,432 KB
testcase_18 AC 312 ms
155,980 KB
testcase_19 AC 722 ms
255,876 KB
testcase_20 AC 1,213 ms
255,124 KB
testcase_21 AC 432 ms
194,360 KB
testcase_22 AC 510 ms
221,412 KB
testcase_23 AC 391 ms
184,112 KB
testcase_24 AC 1,145 ms
256,376 KB
testcase_25 AC 661 ms
256,856 KB
testcase_26 AC 141 ms
96,844 KB
testcase_27 AC 565 ms
239,072 KB
testcase_28 AC 455 ms
201,976 KB
testcase_29 AC 366 ms
172,188 KB
testcase_30 AC 720 ms
256,320 KB
testcase_31 AC 735 ms
256,116 KB
testcase_32 AC 880 ms
258,048 KB
testcase_33 AC 676 ms
256,692 KB
testcase_34 AC 1,075 ms
255,548 KB
testcase_35 AC 879 ms
257,612 KB
testcase_36 AC 1,052 ms
256,208 KB
testcase_37 AC 194 ms
78,128 KB
testcase_38 AC 1,118 ms
255,816 KB
testcase_39 AC 1,003 ms
257,892 KB
testcase_40 AC 1,022 ms
255,184 KB
testcase_41 AC 1,378 ms
255,828 KB
testcase_42 AC 1,259 ms
255,740 KB
testcase_43 AC 1,305 ms
255,460 KB
testcase_44 AC 1,399 ms
254,652 KB
testcase_45 AC 1,401 ms
255,732 KB
testcase_46 AC 1,384 ms
255,988 KB
testcase_47 AC 1,415 ms
256,744 KB
testcase_48 AC 1,402 ms
256,836 KB
testcase_49 AC 1,410 ms
256,516 KB
testcase_50 AC 1,397 ms
254,864 KB
testcase_51 AC 1,408 ms
255,084 KB
testcase_52 AC 1,387 ms
256,248 KB
testcase_53 AC 1,411 ms
255,336 KB
testcase_54 AC 1,389 ms
256,360 KB
testcase_55 AC 1,402 ms
254,940 KB
testcase_56 AC 1,365 ms
255,380 KB
testcase_57 AC 1,374 ms
254,836 KB
testcase_58 AC 1,390 ms
255,444 KB
testcase_59 AC 1,332 ms
256,292 KB
testcase_60 AC 1,413 ms
255,676 KB
testcase_61 AC 44 ms
57,096 KB
testcase_62 AC 45 ms
57,024 KB
testcase_63 AC 1,409 ms
255,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""
Dirichlet Product
"""
def mul(N,K,L,data_as,data_ab,data_bs,data_bb):
    data_rs = [0 for i in range(K+1)]
    data_rb = [0 for i in range(L+1)]

    for i in range(1,K+1):
        for j in range(1,K//i+1):
            data_rs[i*j] += data_as[i] * data_bs[j]

    data_as_cum = [data_as[i] for i in range(K+1)]
    data_bs_cum = [data_bs[i] for i in range(K+1)]
    for i in range(1,K+1):
        data_as_cum[i] += data_as_cum[i-1]
        data_bs_cum[i] += data_bs_cum[i-1]

    def cumA(i):
        if 1<=i<=L:
            return data_ab[i]
        else:
            return data_as_cum[(N//i)]

    def cumB(i):
        if 1<=i<=L:
            return data_bb[i]
        else:
            return data_bs_cum[(N//i)]

    for i in range(1,L+1):
        M = int((N//i)**.5)
        for j in range(1,M+1):
            data_rb[i] += data_as[j] * cumB(i*j)
        for j in range(1,M+1):
            data_rb[i] += data_bs[j] * (cumA(i*j)-cumA(N//M))

    return data_rs,data_rb

def single_mul(N,K,L,a,A,val):
    res = [a[i] for i in range(K+1)]
    Res = [A[i] for i in range(L+1)]

    for i in range(1,K+1):
        if i*val<=K:
            res[i*val] += a[i]

    cum = [a[i] for i in range(K+1)]
    for i in range(1,K+1):
        cum[i] += cum[i-1]

    def cumA(i):
        if 1<=i<=L:
            return A[i]
        else:
            return cum[N//i]

    for i in range(1,L+1):
        Res[i] += cumA(i*val)

    return res,Res

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import gcd,log

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

_N,_K = mi()

N = _K
K = min(N,int(N**.5)+1)
L = K

res = [0 for i in range(K+1)]
res[1] = 1
Res = [0 for i in range(L+1)]
for i in range(1,L+1):
    Res[i] = 1

for i in range(1,_N+1):
    res,Res = single_mul(N,K,L,res,Res,i)

print((Res[1]-1))
0