五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

CF 1440A. Buy the String

2023-06-20 13:38 作者:您是打尖兒還是住店呢  | 我要投稿

You are given four integers n, c0, c1 and h and a binary string s of length n.

A binary string is a string consisting of characters 0 and 1.

You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change.

After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0

?you should pay c0 coins, to buy the character 1 you should pay c1 coins.

Find the minimum number of coins needed to buy the string.

Input

The first line contains a single integer t (1≤t≤10) — the number of test cases. Next 2t lines contain descriptions of test cases.

The first line of the description of each test case contains four integers n, c0, c1, h (1≤n,c0,c1,h≤1000).

The second line of the description of each test case contains the binary string s of length n.

Output

For each test case print a single integer — the minimum number of coins needed to buy the string.


Example

input

6

3 1 1 1

100

5 10 100 1

01010

5 10 1 1

11111

5 1 10 1

11111

12 2 1 10

101110110101

2 100 1 10

00

output

3

52

5

10

16

22

Note

In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin.

In the second test case, you can firstly change 2-nd and 4-th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000. After that, you can buy the string and pay 5?10=50

?coins for that. The total number of coins paid will be 2+50=52.

給定字符串,01字符,其中買0字符的要花c0元,買1字符的要花c1元,如果把0跟1交換的話,要花h元,問如果能最小化買了這個字符串的金額。

主要是判斷2個參數(shù)h+c0跟c1的關(guān)系,還有h+c1跟c0的關(guān)系,即可。

剩下就是hashmap 處理即可;(當然也可用變量存儲)


CF 1440A. Buy the String的評論 (共 條)

分享到微博請遵守國家法律
奉新县| 洪江市| 彭水| 桐乡市| 连城县| 湄潭县| 栖霞市| 攀枝花市| 聊城市| 石河子市| 循化| 乌恰县| 化德县| 岳池县| 临颍县| 郴州市| 石首市| 信阳市| 莒南县| 栖霞市| 柯坪县| 镇远县| 宁武县| 博野县| 大连市| 大邑县| 承德县| 横峰县| 昔阳县| 镇坪县| 大英县| 乐平市| 万全县| 庆元县| 四平市| 佳木斯市| 怀安县| 彰武县| 合阳县| 阿克| 奎屯市|