标签:style blog class code java c
1 /** 2 对于大数的很好的应用,,缩小放大,,保持精度 3 **/ 4 #include <iostream> 5 #include <cmath> 6 #include <algorithm> 7 #include <cstdio> 8 using namespace std; 9 10 int main() 11 { 12 double n,p; 13 int cnt =1; 14 while(cin>>n>>p){ 15 double p1 = log(p+0.0); 16 double p2 = log(1-p+0.0); 17 double s1 = (n+1)*p1; 18 double s2 = (n+1)*p2; 19 double ans =0,c=0; 20 for(int i=0;i<n;i++){ 21 ans += (exp(c+s1)+exp(c+s2))*(n-i); 22 c += log(n+1+i+0.0)-log(i+1+0.0); 23 s1 += p2; 24 s2 += p1; 25 } 26 printf("Case %d: %.6lf\n",cnt++,ans); 27 } 28 return 0; 29 }
hdu 4465 Candy 2012 成都现场赛,布布扣,bubuko.com
标签:style blog class code java c
原文地址:http://www.cnblogs.com/Bang-cansee/p/3724100.html