URAL1573 Alchemy

49 篇文章 0 订阅
1 篇文章 0 订阅

1573. Alchemy

Time limit: 1.0 second
Memory limit: 64 MB
Lich Sandro recently became an expert in alchemy and is very glad because of it. Sure enough, because this skill allows to mix simple potions to obtain more complex ones. Any character (even not skilled in alchemy) is able to make 3 simple potions: red, blue, and yellow. A single reagent is sufficient to make any of them, but the same reagent cannot be used to make potions of different colors. All reagents can be divided into 3 groups according to this rule: yellow (sulphur, unicorn's horn, a poppy boll…), blue (a piece of a meteor, a fang of a dragon turtle…) and red (dragon's eye, ruby, gog's blood…).
Every character would like to prepare other potions. In order to achieve that it is necessary to learn alchemy and to upgrade this skill. A novice alchemist is able to mix the basic potions: yellow and red, red and blue, or blue and yellow to obtain an orange, violet or green potion, respectively. These potions are called composite. An expert alchemist is also able to mix basic and composite potions without messing up their layers (this may lead to an explosion!).
Sandro has 3 bags of reagents, and each bag contains reagents of only one color. There are  B blue,  R red, and  Y yellow reagents. Sandro's collection of reagents is extraordinary, since all the reagents are different!  K reagents of different colors are required to make a potion that makes it posssible to breathe under water. The recipe of this potion is known, and now Sandro would like to know the number of possible ways to prepare it.

Input

The first line contains integers  BR, and  Y;  1 ≤  BRY ≤ 100 . Then the recipe of the potion is given: the second line contains a positive integer  K; the next  K lines contain the colors of the required reagents (“Blue”, “Red”, or “Yellow”). Each word occurs at most once.

Output

Output the number of possible ways to choose a set of reagents to make the potion (sets differing in one or more reagent are considered different; the order of reagents in a set doesn't matter).

Sample

inputoutput
2 3 5
3
Red
Yellow
Blue
30
(题目没看懂,结果百度出了小伙伴的博客......)

#include <cstdlib>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
char s[10];
int main()
{
    int r,y,b;
    int n,ans;
    while(~scanf("%d%d%d",&b,&r,&y))
    {
        ans = 1;
        scanf("%d",&n);
        while(n--)
        {
            scanf("%s",s);
            if(s[0] == 'R') ans *= r;
            if(s[0] == 'B') ans *= b;
            if(s[0] == 'Y') ans *= y;
        }
        cout << ans << endl;
    }
    return 0;
}


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值