CF371C.Hamburgers
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (bread), 'S' (sausage) и 'C' (cheese). The ingredients in the recipe go from bottom to top, for example, recipe "ВSCBS" represents the hamburger where the ingredients go from bottom to top as bread, sausage, cheese, bread and sausage again.
Polycarpus has n__b pieces of bread, n__s pieces of sausage and n__c pieces of cheese in the kitchen. Besides, the shop nearby has all three ingredients, the prices are p__b rubles for a piece of bread, p__s for a piece of sausage and p__c for a piece of cheese.
Polycarpus has r rubles and he is ready to shop on them. What maximum number of hamburgers can he cook? You can assume that Polycarpus cannot break or slice any of the pieces of bread, sausage or cheese. Besides, the shop has an unlimited number of pieces of each ingredient.
波利卡普斯非常喜爱汉堡包,尤其钟爱自己亲手制作的汉堡包。波利卡普斯认为,制作汉堡包仅有三种体面的原料:面包(bread)、香肠(sausage)和奶酪(cheese)。他将自己最钟爱的“波利卡普斯汉堡(Le Hamburger de Polycarpus)”的配方记录为一个仅含字母 'B'(面包)、'S'(香肠)和 'C'(奶酪)的字符串。配方中各字母自下而上表示汉堡包中各层原料的顺序;例如,配方 "BSCBS" 表示一个自下而上依次为:面包、香肠、奶酪、面包、香肠的汉堡包。
波利卡普斯厨房里现有 n_b 片面包、n_s 片香肠和 n_c 片奶酪。此外,附近商店中这三种原料均有售,单价分别为:每片面包 p_b 卢布、每片香肠 p_s 卢布、每片奶酪 p_c 卢布。
波利卡普斯手头有 r 卢布,并准备全部用于采购。他最多能制作多少个汉堡包?你可以假设波利卡普斯不能将任何一片面包、香肠或奶酪切开或分割;此外,商店中每种原料的库存均为无限。
输入格式
The first line of the input contains a non-empty string that describes the recipe of "Le Hamburger de Polycarpus". The length of the string doesn't exceed 100, the string contains only letters 'B' (uppercase English B), 'S' (uppercase English S) and 'C' (uppercase English C).
The second line contains three integers n__b, n__s, n__c (1 ≤ n__b, n__s, n__c ≤ 100) — the number of the pieces of bread, sausage and cheese on Polycarpus' kitchen. The third line contains three integers p__b, p__s, p__c (1 ≤ p__b, p__s, p__c ≤ 100) — the price of one piece of bread, sausage and cheese in the shop. Finally, the fourth line contains integer r (1 ≤ r ≤ 1012) — the number of rubles Polycarpus has.
Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
输入的第一行包含一个非空字符串,描述了“波利卡普斯汉堡”的制作配方。该字符串长度不超过 100,且仅由大写字母 'B'(代表面包)、'S'(代表香肠)和 'C'(代表奶酪)组成。
第二行包含三个整数 nb、ns、nc(1 ≤ nb,ns,nc ≤ 100),分别表示波利卡普斯厨房中面包、香肠和奶酪的现有数量。
第三行包含三个整数 pb、ps、pc(1 ≤ pb,ps,pc ≤ 100),分别表示在商店中购买一片面包、一根香肠和一块奶酪的价格。
最后,第四行包含一个整数 r(1 ≤ r ≤ 1012),表示波利卡普斯拥有的卢布数。
请注意:在 C++ 中读写 64 位整数时,请勿使用 %lld 格式说明符;推荐使用 cin/cout 流或 %I64d 格式说明符。
输出格式
Print the maximum number of hamburgers Polycarpus can make. If he can't make any hamburger, print 0.
输出 Polycarpus 最多能制作的汉堡数量。如果他无法制作任何汉堡,则输出 0。
输入输出样例
输入#1
BBBSSC 6 4 1 1 2 3 4
输出#1
2
输入#2
BBC 1 10 1 1 10 1 21
输出#2
7
输入#3
BSC 1 1 1 1 1 3 1000000000000
输出#3
200000000001
输入解题思路,AI测评打分。不知道怎么写?