#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <string>
#include <sstream>
#include <utility>
#include <ctime>
using std::priority_queue;
using std::vector;
using std::swap;
using std::stack;
using std::sort;
using std::max;
using std::min;
using std::pair;
using std::map;
using std::string;
using std::cin;
using std::cout;
using std::set;
using std::queue;
using std::string;
using std::istringstream;
using std::make_pair;
using std::greater;
using std::endl;
const int MAXN(105);
double table[MAXN][MAXN];
bool not_greater(int fz1, int fm1, int fz2, int fm2)
{
return fz1*fm2 <= fz2*fm1;
}
int main()
{
int T, n_case(0);
scanf("%d", &T);
while(T--)
{
int fz, fm, n;
scanf("%d/%d%d", &fz, &fm, &n);
double prob = (double)fz/fm;
memset(table, 0, sizeof(table));
table[0][0] = 1.0;
int i, j;
for(i = 1; i <= n; ++i)
for(j = 0; not_greater(j, i, fz, fm); ++j)
{
table[i][j] = table[i-1][j]*(1-prob);
if(j)
table[i][j] += table[i-1][j-1]*prob;
}
double ans = 0;
for(i = 0; not_greater(i, n, fz, fm); ++i)
ans += table[n][i];
printf("Case #%d: %d\n", ++n_case, (int)floor(1/ans));
}
return 0;
}
Expect the Expected UVA11427
最新推荐文章于 2023-10-05 06:00:00 发布