#include <iostream>
#include <cmath>
using namespace std;
double ave, winper, loseper;
double n, m;
int main()
{
long int q;
int testcase, i, j, k;
double testave;
cin >> testcase;
while(testcase >= 1)
{
--testcase;
cin >> n >> m;
if(m==1)
{
printf("%d\n", int(n));
continue;
}
winper = n/100;
loseper = 1-winper;
ave = 1 + loseper * m;
for(i=2; i<m; i++)
{
k=q=1;
for(j=2; j<=i; j++) k*=j;
for(j=0; j<i; j++)
{
q*=(m+j);
}
ave += pow(loseper, i) * q / k;
}
ave *= pow(winper, m);
testave = ave;
testave *= 10000;
if(int(testave) % 100 >= 50) testave+=50;
testave /= 100;
cout << int(testave) << endl;
testave=ave=0;
}
return 0;
}
'알고스팟 풀이 > 알고스팟 소스' 카테고리의 다른 글
11. ORIVIRUS (0) | 2015.06.24 |
---|---|
13. FESTIVAL (0) | 2015.06.24 |
14. TRIANGLEPATH (0) | 2015.06.24 |
15. LIS (0) | 2015.06.24 |