hdu 4465 Candy 2012 成都现场赛

 /**
对于大数的很好的应用,,缩小放大,,保持精度
**/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
using namespace std; int main()
{
double n,p;
int cnt =;
while(cin>>n>>p){
double p1 = log(p+0.0);
double p2 = log(-p+0.0);
double s1 = (n+)*p1;
double s2 = (n+)*p2;
double ans =,c=;
for(int i=;i<n;i++){
ans += (exp(c+s1)+exp(c+s2))*(n-i);
c += log(n++i+0.0)-log(i++0.0);
s1 += p2;
s2 += p1;
}
printf("Case %d: %.6lf\n",cnt++,ans);
}
return ;
}
上一篇:C3p0实践


下一篇:[区块链]POW 与POS