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