結果

問題 No.1532 Different Products
ユーザー mkawa2mkawa2
提出日時 2023-10-04 16:06:56
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,260 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 303,336 KB
最終ジャッジ日時 2023-10-04 16:07:16
合計ジャッジ時間 12,167 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,632 KB
testcase_01 AC 1,352 ms
250,964 KB
testcase_02 AC 87 ms
76,376 KB
testcase_03 AC 75 ms
71,660 KB
testcase_04 AC 77 ms
71,220 KB
testcase_05 AC 76 ms
71,448 KB
testcase_06 AC 96 ms
76,516 KB
testcase_07 AC 104 ms
77,252 KB
testcase_08 AC 116 ms
79,596 KB
testcase_09 AC 427 ms
108,988 KB
testcase_10 AC 1,598 ms
281,836 KB
testcase_11 AC 1,216 ms
219,636 KB
testcase_12 TLE -
testcase_13 AC 2,079 ms
282,988 KB
testcase_14 TLE -
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()
    res=0
    if n==2:
        res+=2
    elif (n-1,k) in dp:
        res+=dp[n-1,k]
    else:
        stack.append((n,k))
        stack.append((n-1,k))
    if k>=n:
        if k//n==1 or n==2:
            res+=2
        elif (n-1,k//n) in dp:
            res+=dp[n-1,k//n]
        else:
            stack.append((n,k))
            stack.append((n-1,k//n))
    dp[n,k]=res

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