Context
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.
TheProblem
In our particular computerized kitchen, ingredients are named bycapital letters: A, B, C, D... Thus, to make a pizza MARGARITA we needas many ingredients as their letters, i.e. one M, three A, two R, oneG, 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 pizzasMARGARITA can be made. Note that there may be leftover ingredients, andalso there may be unnecessary ingredients, such as B.
TheInput
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.
TheOutput
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.
SampleInput
5
MARGARITA
AAAAAAMMRRTITIGGRRRRRRRR
AMARGITA
BOLOGNESACAPRICHOSATOMATERA
ABCDEFGHIJKLMNOPQRSTUVWXYZ
SampleOutput
1 2 0 1 0
#include<stdio.h>
#include<string.h>
int min(int *a)
{
int i,min=a[0];
for(i=0;i<6;i++)
if(a[i]<min)
min=a[i];
return min;
}
int main()
{
int n,i;
char b[605];
scanf("%d",&n);
while(n--)
{
int a[6]={0};
scanf("%s",b);
for(i=0;i<strlen(b);i++)
{
if(b[i]=='M') a[0]++;
if(b[i]=='A') a[1]++;
if(b[i]=='R') a[2]++;
if(b[i]=='G') a[3]++;
if(b[i]=='I') a[4]++;
if(b[i]=='T') a[5]++;
}
a[1]/=3; a[2]/=2;
printf("%d\n",min(a));
}
return 0;
}
本文详细介绍了经典比萨Margherita的起源故事,包括它如何得名以及背后的意大利国旗颜色寓意。文章还提供了一个计算机化的厨房环境下的实际应用案例,解释如何利用给定的食材制作比萨Margherita,并通过示例输入输出了制作过程。通过代码实现,文章指导读者如何计算可用食材能制作多少份比萨Margherita。

236

被折叠的 条评论
为什么被折叠?



