結果

問題 No.1532 Different Products
ユーザー mkawa2mkawa2
提出日時 2023-10-04 16:23:00
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,380 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 562,712 KB
最終ジャッジ日時 2023-10-04 16:23:25
合計ジャッジ時間 16,490 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
75,652 KB
testcase_01 AC 982 ms
224,260 KB
testcase_02 AC 71 ms
71,628 KB
testcase_03 AC 69 ms
71,292 KB
testcase_04 AC 69 ms
71,456 KB
testcase_05 AC 68 ms
71,580 KB
testcase_06 AC 81 ms
76,288 KB
testcase_07 AC 92 ms
77,304 KB
testcase_08 AC 100 ms
78,832 KB
testcase_09 AC 293 ms
116,840 KB
testcase_10 AC 1,194 ms
270,464 KB
testcase_11 AC 889 ms
202,668 KB
testcase_12 AC 3,073 ms
412,216 KB
testcase_13 AC 1,371 ms
255,284 KB
testcase_14 TLE -
testcase_15 AC 108 ms
81,760 KB
testcase_16 AC 1,136 ms
254,704 KB
testcase_17 AC 882 ms
204,728 KB
testcase_18 AC 618 ms
149,632 KB
testcase_19 AC 2,947 ms
408,172 KB
testcase_20 MLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 63)
md = 10**9+7
# md = 998244353

N, K = LI()

if N == 1 or K == 1:
    print(1)
    exit()

dp = {}
stack = [(N, K)]
while stack:
    n, k = stack.pop()
    kn = k//n
    if n == 2:
        dp[n, k] = 2
        if k >= n: dp[n, k] += 2
    else:
        b1 = (n-1, k) not in dp
        b2 = kn > 1 and (n-1, kn) not in dp
        if b1 or b2:
            stack.append((n, k))
            if b1: stack.append((n-1, k))
            if b2: stack.append((n-1, kn))
        else:
            dp[n, k] = dp[n-1, k]
            if kn == 1:
                dp[n, k] += 2
            elif kn > 1:
                dp[n, k] += dp[n-1, kn]

print(dp[N, K]-1)
0