hdu_5139 概率问题

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    int t;scanf("%d",&t);
    int c=t;
    while(t--){
        long long x;
        int b;
        double cnt=1.0;
        long long sum;
        scanf("%lld%d",&x,&b);
        double a=1-1.0/x;
        for(int i=0;i<b;i++)
            cnt*=a;
        cnt=1.0-cnt;
        sum=(1+x)*x/2.0;
        double ans=sum*cnt;
        printf("Case #%d: %.3lf\n",c-t,ans);
    }
    return 0;
}

注意精度

posted @ 2015-01-20 23:43  JarvisLau  阅读(131)  评论(0编辑  收藏  举报