update
This commit is contained in:
parent
df4859179a
commit
e28ba394cc
23
src/oj8782/oj8782.py
Normal file
23
src/oj8782/oj8782.py
Normal file
@ -0,0 +1,23 @@
|
||||
from typing import List
|
||||
|
||||
n,k = map(int,input().split(' '))
|
||||
|
||||
c=" "+input()
|
||||
num:List[List[int]] = [[0 for _ in range(n+1)] for _ in range(n+1)]
|
||||
dp:List[List[int]] = [[0 for _ in range(n+1)] for _ in range(n+1)]
|
||||
|
||||
for i in range(1,n+1):
|
||||
num[i][i] = int(c[i])
|
||||
# print(num[i][i])
|
||||
for j in range(i+1,n+1):
|
||||
num[i][j] = num[i][j-1]*10 + int(c[j])
|
||||
# print(num[i][j])
|
||||
dp[i][0] = num[1][i]
|
||||
|
||||
for j in range(1,k+1):
|
||||
for i in range(j+1,n+1):
|
||||
for fk in range(j-1,i):
|
||||
# print(i, j, dp[i][j], dp[k][j-1]*num[fk+1][i])
|
||||
dp[i][j] = max(dp[i][j], dp[fk][j-1]*num[fk+1][i])
|
||||
|
||||
print(dp[n][k])
|
Loading…
Reference in New Issue
Block a user