记录编号 590942 评测结果 AAAAAAAAAA
题目名称 [HNOI 2015]亚瑟王 最终得分 100
用户昵称 Gravatar┭┮﹏┭┮ 是否通过 通过
代码语言 C++ 运行时间 3.683 s
提交时间 2024-07-13 15:53:59 内存使用 4.56 MiB
显示代码纯文本
#include <bits/stdc++.h> 
using namespace std;
#define ll long long
const int N = 300;
const ll mod = 998244353;

ll read(){
    ll x = 0,f = 1;char c = getchar();
    for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
    for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
    return x * f;
}


int t,n,m;
double f[N][N],p[N],d[N];


int main(){
    freopen("arthur.in","r",stdin);
    freopen("arthur.out","w",stdout);
    t = read();
    while(t--){
        memset(f,0,sizeof f);
        n = read(),m = read();
        for(int i = 1;i <= n;i++)scanf("%lf%lf",&p[i],&d[i]);
        f[0][0] = 1;
        for(int i = 1;i <= n;i++){
            for(int j = 0;j <= i;j++){
                f[i][j] += f[i-1][j] * pow(1 - p[i],m-j) ;
                f[i][j] += f[i-1][j-1] * (1 - pow(1 - p[i],m-j+1));
            }
        }
        double ans = 0;
        for(int i = 1;i <= n;i++){
            double s = 0;
            for(int j = 0;j <= m;j++)s += f[i-1][j] * (1 - pow(1 - p[i],m-j));
            ans += s * d[i];
        }
        printf("%.10lf\n",ans);
    }
    
    

    
    return 0;
    
}