Everybody loves pizza: Margarita, Four cheese, Salami,Caprichosa, Neapolitan, Hawaiian... The famous pizza Margarita is namedafter the Italian Queen Margarita of Savoy. It is said that the chefRaffaele Esposito gave her to choose from a variety of pizzas he hadprepared specially for the Queen. Margarita chose this pizza in honorof the colors of the Italian flag: red tomato, white cheese, and greenbasil.
However, some people argue that, in fact, Queen Margarita didnot like onion, and as all the other pizzas had onion, she had nochoice but that pizza.
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 pizzasMARGARITA can be made. Note that there may be leftover ingredients, andalso there may be unnecessary ingredients, such as B.
The first line contains a natural number, N, which indicatesthe number of test cases.
Each test case is given in one line. This line contains aseries of capital letters from A to Z, which can be messy and may berepeated. At most one line can have 600 characters.
For each test case, you must indicate how many pizzasMARGARITA can be made with the letters available, taking into accountthat there may be spare letters.
5
MARGARITA
AAAAAAMMRRTITIGGRRRRRRRR
AMARGITA
BOLOGNESACAPRICHOSATOMATERA
ABCDEFGHIJKLMNOPQRSTUVWXYZ
1 2 0 1 0
#include
#include
int min(int *a)
{
int i,min=a[0];
for(i=0;i<6;i++)
if(a[i]