12626 - I ❤ Pizza

 G- I ❤ Pizza 

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.

Una rica pizza

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;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值