From e28ba394cc496777c83a02adc9ee59b8311cee19 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Fri, 18 Oct 2024 11:14:45 +0800 Subject: [PATCH] update --- src/oj8782/oj8782.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/oj8782/oj8782.py diff --git a/src/oj8782/oj8782.py b/src/oj8782/oj8782.py new file mode 100644 index 0000000..3026c6e --- /dev/null +++ b/src/oj8782/oj8782.py @@ -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]) \ No newline at end of file