mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
34d0415174
4600-4699
42 lines
842 B
C++
42 lines
842 B
C++
#include <cstdio>
|
|
#include <iostream>
|
|
#include <cstring>
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
using namespace std;
|
|
double solve0(int m,int n)
|
|
{
|
|
double ans=0;
|
|
for(int i=0;i<=n-1;i++)
|
|
ans+=pow(1.0*m,i);
|
|
return ans;
|
|
}
|
|
double solve1(int m,int n)
|
|
{
|
|
double ans=0;
|
|
double tmp=1;
|
|
for(int i=1;i<=n;i++)
|
|
{
|
|
ans+=tmp;
|
|
tmp*=(m+0.0)/(m-i);
|
|
}
|
|
return ans;
|
|
}
|
|
int main()
|
|
{
|
|
int t;
|
|
while(scanf("%d",&t)!=EOF)
|
|
{
|
|
while(t--)
|
|
{
|
|
int n,m,op;
|
|
scanf("%d%d%d",&op,&m,&n);
|
|
if(op==0)
|
|
printf("%.9lf\n",solve0(m,n));
|
|
else
|
|
printf("%.9lf\n",solve1(m,n));
|
|
}
|
|
}
|
|
return 0;
|
|
}
|