結果
問題 |
No.1532 Different Products
|
ユーザー |
![]() |
提出日時 | 2021-06-04 22:22:29 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 649 bytes |
コンパイル時間 | 186 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 1,037,932 KB |
最終ジャッジ日時 | 2024-11-19 20:20:34 |
合計ジャッジ時間 | 199,065 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 MLE * 1 |
other | AC * 17 TLE * 15 MLE * 30 |
ソースコード
N,K=map(int,input().split()) stack=[(N,K,0),(N,K,1)] memo={} ans=[] while(stack): n,k,d=stack.pop() if d==1: if (n,k) in memo: ans.append(memo[(n,k)]) elif k==0: memo[(n,k)]=0 ans.append(0) elif n==0: memo[(n,k)]=1 ans.append(1) else: stack.append((n-1,k,0)) stack.append((n-1,k,1)) stack.append((n-1,k//n,0)) stack.append((n-1,k//n,1)) else: if (n,k) in memo: pass else: ans.append(ans.pop()+ans.pop()) memo[(n,k)]=ans[-1] print(memo[(n,k)]-1)