結果

問題 No.1532 Different Products
ユーザー mkawa2mkawa2
提出日時 2023-10-04 16:22:11
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,378 bytes
コンパイル時間 476 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 559,504 KB
最終ジャッジ日時 2023-10-04 16:22:29
合計ジャッジ時間 15,163 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,288 KB
testcase_01 AC 1,083 ms
225,216 KB
testcase_02 AC 73 ms
71,160 KB
testcase_03 AC 70 ms
71,292 KB
testcase_04 AC 70 ms
71,404 KB
testcase_05 AC 70 ms
71,332 KB
testcase_06 AC 82 ms
76,220 KB
testcase_07 AC 94 ms
77,004 KB
testcase_08 AC 102 ms
78,772 KB
testcase_09 AC 318 ms
117,716 KB
testcase_10 AC 1,209 ms
270,436 KB
testcase_11 AC 872 ms
203,724 KB
testcase_12 AC 3,089 ms
412,044 KB
testcase_13 AC 1,435 ms
255,508 KB
testcase_14 MLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
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