QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 100

#5460. 数字之和

统计

给定 $n$ 个 '1' 到 '9' 之间的数字,你可以在其中添加 $k$ 个 '+' 号将其变为一个表达式,求该表达式的最小值。

输入格式

输入包含多组测试数据。 第一行包含一个整数 $T$ ($1 \le T \le 2 \times 10^4$),表示测试数据的组数。 对于每组测试数据: 第一行包含两个整数 $n$ ($2 \le n \le 2 \times 10^5$) 和 $k$ ($1 \le k \le 6, k < n$),分别表示数字的个数和 '+' 号的个数。 第二行包含一个长度为 $n$ 的字符串,由 '1' 到 '9' 之间的数字组成。 所有测试数据的 $n$ 之和不超过 $2 \times 10^5$。

输出格式

对于每组测试数据,输出一行答案。

样例

样例输入 1

2
8 1
45455151
2 1
42

样例输出 1

9696
6

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.