[UVA][Easy] 12626 - I Pizza@Morris' Blog|PChome Online 人新台
2013-05-29 16:29:08| 人2,300| 回0 | 上一篇 | 下一篇

[UVA][Easy] 12626 - I Pizza

0 收藏 0 0 站台

 G - I Pizza 

Context

Everybody loves pizza: Margarita, Four cheese, Salami, Caprichosa, Neapolitan, Hawaiian... The famous pizza Margarita is named after the Italian Queen Margarita of Savoy. It is said that the chef Raffaele Esposito gave her to choose from a variety of pizzas he had prepared specially for the Queen. Margarita chose this pizza in honor of the colors of the Italian flag: red tomato, white cheese, and green basil.

Una rica pizza

However, some people argue that, in fact, Queen Margarita did not like onion, and as all the other pizzas had onion, she had no choice but that pizza.

The Problem

In our particular computerized kitchen, ingredients are named by capital letters: A, B, C, D... Thus, to make a pizza MARGARITA we need as many ingredients as their letters, i.e. one M, three A, two R, one G, one I, and one T.

For example, if we have the ingredients:

AAAAAAMMRRTITIGGRRRRRRRR

Then we can make 2 pizzas MARGARITA, and still spare some R.

Given a set of ingredients, you have to say how many pizzas MARGARITA can be made. Note that there may be leftover ingredients, and also there may be unnecessary ingredients, such as B.

The Input

The first line contains a natural number, N, which indicates the number of test cases.

Each test case is given in one line. This line contains a series of capital letters from A to Z, which can be messy and may be repeated. At most one line can have 600 characters.

The Output

For each test case, you must indicate how many pizzas MARGARITA can be made with the letters available, taking into account that there may be spare letters.

Sample Input

5
MARGARITA
AAAAAAMMRRTITIGGRRRRRRRR
AMARGITA
BOLOGNESACAPRICHOSATOMATERA
ABCDEFGHIJKLMNOPQRSTUVWXYZ

Sample Output

1
2
0
1
0


OMP'13
Facultad de Informática
Universidad de Murcia

定材料要求作一位的 pizza, 所有材料的量, 最多能作多少片 pizza

#include <stdio.h>
#include <algorithm>
using namespace std;
int main() {
    int t;
    char s[605];
    scanf("%d", &t);
    while(t--) {
        scanf("%s", s);
        int ascii[128] = {};
        for(int i = 0; s[i]; i++)
            ascii[s[i]]++;
        int ret = 0xffff;
        ret = min(ret, ascii['M']/1);
        ret = min(ret, ascii['A']/3);
        ret = min(ret, ascii['R']/2);
        ret = min(ret, ascii['G']/1);
        ret = min(ret, ascii['T']/1);
        ret = min(ret, ascii['I']/1);
        printf("%d\n", ret);
    }
    return 0;
}

台: Morris
人(2,300) | 回(0)| 推 (0)| 收藏 (0)|
全站分: 不分 | 人分: UVA |
此分下一篇:[UVA][Easy] 12614 - Earn For Future
此分上一篇:[UVA][Easy] 12611 - Beautiful Flag

是 (若未登入"人新台"看不到回覆唷!)
* 入:
入片中算式的果(可能0) 
(有*必填)
TOP
全文
ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86