結果

問題 No.2846 Birthday Cake
ユーザー hiro1729
提出日時 2024-08-23 21:21:22
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 374 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 82,580 KB
実行使用メモリ 176,008 KB
最終ジャッジ日時 2024-08-23 21:21:27
合計ジャッジ時間 4,808 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other -- * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from fractions import Fraction

K, N = map(int, input().split())
dp = defaultdict(int)
dp[(0, 1)] = 1
for i in range(K):
	ndp = defaultdict(int)
	for j, c in dp.items():
		for k in range(1, N + 1):
			f = Fraction(j[0], j[1]) + Fraction(1, k)
			if f > 1:
				continue
			ndp[(f.numerator, f.denominator)] += c
	dp = ndp
print(dp[(1, 1)])
0