1. Fred Howard
2. ASCL #1
3. Senior
4. IMSA
5. PC
6. C++
7. acsl1.cpp
8. acsl1.exe
9. Put the data, space delimited, in acsl1.in. Run the exe.
The output will be
in acsl1.out. Example input:
2 1 2 3 N r b
*/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
ofstream fout ("acsl1.out");
ifstream
fin ("acsl1.in");
int
count(int n, int r, int b, int w, int
t, string args)
{
if(n
== 0) return 1;
if(args[n - 1] == 'R') return r*count(n - 1, r - t, b, w, t, args);
if(args[n - 1] == 'B') return b*count(n - 1, r, b - t, w, t, args);
if(args[n - 1] == 'W') return w*count(n - 1, r, b, w - t, t, args);
if(args[n - 1] == 'r') return b*count(n - 1, r, b - t, w, t, args) + w*count(n - 1, r, b, w - t, t, args);
if(args[n - 1] == 'b') return r*count(n - 1, r - t, b, w, t, args) + w*count(n - 1, r, b, w - t, t, args);
if(args[n - 1] == 'w') return r*count(n - 1, r - t, b, w, t, args) + b*count(n - 1, r, b - t, w, t, args);
}
int
main()
{
for(int i = 0; i
< 5; i++)
{
int n, r, b, w, t = 0;
char y = ' ';
fin >> n >> r >> b >> w;
if(n > 1)
fin >> y;
if(y == 'N')
t = 1;
string args = "";
for(int j = 0; j < n; j++)
{
fin >> y;
args += y;
}
fout << (i
+ 1) << ". " << count(n, r, b,
w, t, args) << "/";
int denom
= 1, marbles = r + b + w;
while(n > 0)
{
n--;
denom *= marbles;
marbles -= t;
}
fout << denom
<< endl;
}
}