just the rule of multiplication in combinatorics... just one problem - the sequence of colors, but many 'if's will save the World! Use set data structure Add each color from input to a set Check the set for red, blue and yellow Can somebody give me the whole explanation to this problem. Thanks beforehand! If you have two different sets A = {a1, a2, a3} and B = {b1, b2, b3, b4} then we have |A| * |B| = 3 * 4 = 12 ways to choose a pair (a[i], b[j]).   i\j   b[1]  b[2]  b[3]  b[4] a[1] [1,1] [1,2] [1,3] [1,4] a[2] [2,1] [2,2] [2,3] [2,4] a[3] [3,1] [3,2] [3,3] [3,4]   Modern language solution looks like that: map<string, int> cnt; for (auto color : {"Blue", "Red", "Yellow"})   cin >> cnt[color];   int colors; cin >> colors;   int ways = 1; for (int i = 0; i < colors; i++) {   string color;   cin >> color;     ways *= cnt[color]; }   cout << ways;   Edited by author 24.11.2016 16:04   Edited by author 24.11.2016 16:07   if(s.equals("Blue")|| s.equals("blue"))   if(s.equals("Red") || s.equals("red"))   if(s.equals("Yellow") || s.equals("yellow")) Can Smb Explain The Prob. Or The Sample Output I got AC, but while looking at your solutions, i have guessed following:   Nobody paid attention, that here may be more, than 3 potions: Total number of types of any potion is equal to 15:   B, R, Y;   B + R = V (Violet) B + Y = G (Green) R + Y = O (Orange)   Proceed:   B + V = BV; R + V = RV; Y + V = YV;   and etc: BO, RO, YO, BG, RG, YG - "expert" potions; Sandro can combine any type of potions and any number less or equal than 15;   Folowing to the state of this problem, we should consider any recipes of interesting final potion, and these recipes could include any of K <= 15 reagents - other potions; We also should recognize, what type of advanced potions Sandro can prepare, using his start reagents; And add new occasions into the answer.   Sry for English, but i think - w/o considering the above, actual solution isn't correct.   Edited by author 22.08.2011 01:36   Edited by author 22.08.2011 01:36 WTF?   In the recipe thtre could be only “Blue”, “Red”, or “Yellow”. No Blue-Violet or Yellow-Orange. So if u even make some "expert" poisons, you're not able to do needed poison.   Just use initial poisons. Please explain me this problem>Thank!!! Give me some tests,please,because I think I don't understand problem correctly,please.Thank in advance!!!     Edited by author 16.02.2008 20:28 this problem seems hard at first, but it's very easy   2 4 5 3 Red Yellow Blue >40   3 4 5 3 Red Yellow Blue >60   3 4 5 3 Red Yellow >36   3 4 5 2 Red Yellow >20   3 4 5 2 Blue Thank you for tests!!!I have just last questions:can k be more than 3(k>3)and in 3-th & 5-th of your tests why there is only 2(in 3-th test) and 1(in 5-th test) strings,while k=3(in 3-th test) and k=2(in 5-th test). Thank in advance!!!     Edited by author 17.02.2008 00:30 no, k <= 3 and I gave you some wrong tests) 3 4 5 3 Red Yellow >36 - can't be(k must be 2)   3 4 5 2 Blue Red >12 Thank you very much!!!I get AC!!!   Edited by author 17.02.2008 19:33 Test is wrong (Alexander (201 - P TNU)). If input: 3 4 5 2 Red Yellow Output must be 20, not 36.   Edited by author 25.05.2010 21:56 I think that this task describes the alchemy system from epic game M&M 8 (it's not 6 or 7, because in previous parts player couldn't play lich, but in 8 he could if he completed quest for necromancer). I love this game! Thanks to author, he caused nostalgia...   Tell me, if I made mistake truying to identify the game. :) here my code: #include<iostream> using namespace std; int main() {     int flag[3];     int b,r,y;     cin>>b>>r>>y;     int n,i,j,k;     char str[3][10];     cin>>n;     i=0;     while(i<n)         cin>>str[i++];     for(i=0;i<n;i++)     {         if(str[i][0]=='B'||str[i][0]=='b')             flag[0]=1;         if(str[i][0]=='R'||str[i][0]=='r')             flag[1]=1;         if(str[i][0]=='Y'||str[i][0]=='y')             flag[2]=1;     }     int sum=1;     if(flag[0]==1)         sum*=b;     if(flag[1]==1)         sum*=r;     if(flag[2]==1)         sum*=y;     cout<<sum<<endl;     return 0; }   can anybody help me??? You didn't initialized "flag" and it contains random values. thanks,after i change "flag[3]=0;",i got a AC!  |  
  |