아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Sum of Numbers

면접 대비

시간 제한1초메모리 제한1024 MB

요약
자릿수 문자열을 정확히 k개의 더하기 기호로 잘라 k+1개의 수를 만들고, 그 합이 최소가 되도록 자르는 위치를 정한다.
난이도

보통10점 중 6점

유형
그리디, 동적 계획법, 문자열, 수학
정답자
아직 제출이 없습니다

문제

Given nn digits from '1' to '9', you can add kk '+' to turn it into an expression. Find the minimum value of the expression.

입력

There are multiple test cases.

The first line of the input contains one integer TT (1≤T≤2⋅1041\le T\le 2\cdot 10^4) --- the number of test cases.

For each test case:

The first line contains two integers nn (2≤n≤2⋅1052\le n\le 2\cdot 10^5) and kk (1≤k≤61\le k\le 6, k\<nk\<n) --- the number of digits and the number of '+'.

The second line contains a string of length nn, which consists of digits from '1' to '9'.

The sum of nn over all test cases does not exceed 2⋅1052\cdot 10^5.

출력

For each test case, output the answer in one line.

예제1

  1. 예제 1

    입력
    2
    8 1
    45455151
    2 1
    42
    
    예상 출력
    9696
    6