結果

問題 No.1532 Different Products
ユーザー PCTprobabilityPCTprobability
提出日時 2021-05-02 17:13:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,493 ms / 4,000 ms
コード長 1,996 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 257,424 KB
最終ジャッジ日時 2024-10-10 04:51:09
合計ジャッジ時間 54,705 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
56,732 KB
testcase_01 AC 311 ms
144,036 KB
testcase_02 AC 51 ms
62,028 KB
testcase_03 AC 50 ms
57,956 KB
testcase_04 AC 46 ms
57,680 KB
testcase_05 AC 46 ms
56,472 KB
testcase_06 AC 67 ms
67,792 KB
testcase_07 AC 71 ms
70,068 KB
testcase_08 AC 72 ms
72,392 KB
testcase_09 AC 177 ms
108,008 KB
testcase_10 AC 381 ms
173,272 KB
testcase_11 AC 327 ms
151,424 KB
testcase_12 AC 798 ms
256,128 KB
testcase_13 AC 568 ms
232,064 KB
testcase_14 AC 1,266 ms
255,920 KB
testcase_15 AC 178 ms
107,632 KB
testcase_16 AC 339 ms
155,344 KB
testcase_17 AC 368 ms
165,888 KB
testcase_18 AC 331 ms
156,316 KB
testcase_19 AC 770 ms
255,720 KB
testcase_20 AC 1,269 ms
256,068 KB
testcase_21 AC 448 ms
194,572 KB
testcase_22 AC 531 ms
222,092 KB
testcase_23 AC 409 ms
183,228 KB
testcase_24 AC 1,185 ms
255,844 KB
testcase_25 AC 699 ms
257,424 KB
testcase_26 AC 154 ms
97,716 KB
testcase_27 AC 595 ms
239,456 KB
testcase_28 AC 468 ms
202,808 KB
testcase_29 AC 383 ms
172,864 KB
testcase_30 AC 751 ms
256,832 KB
testcase_31 AC 771 ms
256,036 KB
testcase_32 AC 917 ms
257,176 KB
testcase_33 AC 715 ms
256,256 KB
testcase_34 AC 1,155 ms
255,360 KB
testcase_35 AC 917 ms
257,152 KB
testcase_36 AC 1,106 ms
255,744 KB
testcase_37 AC 204 ms
78,080 KB
testcase_38 AC 1,154 ms
255,488 KB
testcase_39 AC 1,028 ms
256,300 KB
testcase_40 AC 1,057 ms
255,488 KB
testcase_41 AC 1,436 ms
255,872 KB
testcase_42 AC 1,299 ms
254,848 KB
testcase_43 AC 1,346 ms
255,232 KB
testcase_44 AC 1,448 ms
254,720 KB
testcase_45 AC 1,483 ms
254,848 KB
testcase_46 AC 1,493 ms
255,360 KB
testcase_47 AC 1,465 ms
255,232 KB
testcase_48 AC 1,463 ms
255,488 KB
testcase_49 AC 1,435 ms
255,324 KB
testcase_50 AC 1,446 ms
254,592 KB
testcase_51 AC 1,462 ms
254,976 KB
testcase_52 AC 1,452 ms
255,616 KB
testcase_53 AC 1,462 ms
255,104 KB
testcase_54 AC 1,414 ms
255,252 KB
testcase_55 AC 1,439 ms
254,976 KB
testcase_56 AC 1,407 ms
254,976 KB
testcase_57 AC 1,414 ms
254,592 KB
testcase_58 AC 1,454 ms
255,360 KB
testcase_59 AC 1,382 ms
256,128 KB
testcase_60 AC 1,465 ms
255,360 KB
testcase_61 AC 50 ms
56,036 KB
testcase_62 AC 51 ms
56,448 KB
testcase_63 AC 1,450 ms
254,976 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)

if K==1 :
  print(1)
else:
  print((Res[1]-1))
0