当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6583:Typewriter

题目描述
One day, Jerry found a strange typewriter. This typewriter has $2$ input modes: pay $p$ coins to append an arbitrary single letter to the back, or $q$ coins to copy a substring that has already been outputted and paste it in the back.
Jerry now wants to write a letter to Tom. The letter is a string $S$ which contains only lowercase Latin letters. But as Jerry is not very wealthy, he wants to know the minimum number of coins he needs to write this letter.
输入解释
This problem contains multiple test cases. Process until the end of file.
For each test case, the first line contains string $S$ ($|S| \le 2 \times 10 ^ 5, \sum |S| \leq 5\times 10 ^ 6$), consisting of only lowercase Latin letters. And the second line contains $2$ integers $p$ and $q$ ($1 \leq p,q < 2^{31}$).
输出解释
For each test case, output one line containing the minimum number of coins Jerry needs to pay.
输入样例
abc
1 2
aabaab
2 1
输出样例
3
6
来自杭电HDUOJ的附加信息
Recommend

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6583

最后修改于 2020-10-25T23:32:31+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000/1500MS(Java/Others) 262144/262144K(Java/Others)