Poj 2151 Check the difficulty of problems (概率DP)

本文深入探讨了在编程竞赛中如何合理安排问题难度,确保每支队伍至少解决一道题,同时冠军队伍能够解决指定数量的问题。通过概率DP算法,计算出所有队伍至少解决一题且冠军队至少解决特定数量问题的概率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Check the difficulty of problems
Time Limit: 2000MS Memory Limit: 65536K
Total Submissions: 5779 Accepted: 2518

Description

Organizing a programming contest is not an easy job. To avoid making the problems too difficult, the organizer usually expect the contest result satisfy the following two terms:
1. All of the teams solve at least one problem.
2. The champion (One of those teams that solve the most problems) solves at least a certain number of problems.

Now the organizer has studied out the contest problems, and through the result of preliminary contest, the organizer can estimate the probability that a certain team can successfully solve a certain problem.

Given the number of contest problems M, the number of teams T, and the number of problems N that the organizer expect the champion solve at least. We also assume that team i solves problem j with the probability Pij (1 <= i <= T, 1<= j <= M). Well, can you calculate the probability that all of the teams solve at least one problem, and at the same time the champion team solves at least N problems?

Input

The input consists of several test cases. The first line of each test case contains three integers M (0 < M <= 30), T (1 < T <= 1000) and N (0 < N <= M). Each of the following T lines contains M floating-point numbers in the range of [0,1]. In these T lines, the j-th number in the i-th line is just Pij. A test case of M = T = N = 0 indicates the end of input, and should not be processed.

Output

For each test case, please output the answer in a separate line. The result should be rounded to three digits after the decimal point.

Sample Input

2 2 2
0.9 0.9
1 0.9
0 0 0

Sample Output

0.972




看完题目后如果知道概率DP的话,应该都能想到。关键是怎么用。


题意:
ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率
问 每队至少解出一题且冠军队至少解出N道题的概率。


思路:

用dp[i][j][k]表示,第i个队,在前j题,解出k道题的概率。

s[i][k]代表第i个队解出题<=k个的概率


#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
double p[1100][40],dp[1100][40][40],pro[1100][40];
int n,m,t;
int main()
{
    int i,j,k;
    while(scanf("%d%d%d",&m,&t,&n)!=EOF&&n&&m&&t)
    {
        memset(dp,0,sizeof(dp));
        memset(pro,0,sizeof(pro));
        for(i=1;i<=t;i++)
        {
            for(j=1;j<=m;j++)
            {
                scanf("%lf",&p[i][j]);//第i个人解出第j个题的概率,(输入最好,以1为下标开始,以防数组跃界,并容易选择基)
            }
        }
        for(i=1;i<=t;i++)
        {
            dp[i][0][0]=1;//题目数为1-m,所以解出第零个题的概率一定1,(以此作为加的基数)
            for(j=1;j<=m;j++)
            dp[i][j][0]=dp[i][j-1][0]*(1-p[i][j]); //先推i个队,在前j道题中做出0题的概率,以此做基推后边
            for(j=1;j<=m;j++)
            {
                for(k=1;k<=j;k++)
                {
                    dp[i][j][k]=dp[i][j-1][k-1]*(p[i][j])+dp[i][j-1][k]*(1-p[i][j]);//当前的状态和前面的状态及现在能做出题目的概率相关
                }
            }
            pro[i][0]=dp[i][m][0];//第i队做出0<=题的概率,和在m个题中没做出题目的概率相同。
            for(k=1;k<=m;k++)
              pro[i][k]=pro[i][k-1]+dp[i][m][k];//当前做出题目<=k道的概率一定比在m道中做出k道题的概率大,肯定是由上一中情况推来的加上
        }
        double an1=1,an2=1;
        for(i=1;i<=t;i++)
        {
            an1*=(1-pro[i][0]);//此是各队做出题数>=1到的总概率
            an2*=(pro[i][n-1]-pro[i][0]);//每个队做出的题目个数在1~n-1的总概率<span style="white-space:pre">	</span>
        }
        printf("%.3f\n",an1-an2);
    }
    return 0;
}


标题基于SpringBoot+Vue的社区便民服务平台研究AI更换标题第1章引言介绍社区便民服务平台的研究背景、意义,以及基于SpringBoot+Vue技术的研究现状和创新点。1.1研究背景与意义分析社区便民服务的重要性,以及SpringBoot+Vue技术在平台建设中的优势。1.2国内外研究现状概述国内外在社区便民服务平台方面的发展现状。1.3研究方法与创新点阐述本文采用的研究方法和在SpringBoot+Vue技术应用上的创新之处。第2章相关理论介绍SpringBoot和Vue的相关理论基础,以及它们在社区便民服务平台中的应用。2.1SpringBoot技术概述解释SpringBoot的基本概念、特点及其在便民服务平台中的应用价值。2.2Vue技术概述阐述Vue的核心思想、技术特性及其在前端界面开发中的优势。2.3SpringBoot与Vue的整合应用探讨SpringBoot与Vue如何有效整合,以提升社区便民服务平台的性能。第3章平台需求分析与设计分析社区便民服务平台的需求,并基于SpringBoot+Vue技术进行平台设计。3.1需求分析明确平台需满足的功能需求和性能需求。3.2架构设计设计平台的整体架构,包括前后端分离、模块化设计等思想。3.3数据库设计根据平台需求设计合理的数据库结构,包括数据表、字段等。第4章平台实现与关键技术详细阐述基于SpringBoot+Vue的社区便民服务平台的实现过程及关键技术。4.1后端服务实现使用SpringBoot实现后端服务,包括用户管理、服务管理等核心功能。4.2前端界面实现采用Vue技术实现前端界面,提供友好的用户交互体验。4.3前后端交互技术探讨前后端数据交互的方式,如RESTful API、WebSocket等。第5章平台测试与优化对实现的社区便民服务平台进行全面测试,并针对问题进行优化。5.1测试环境与工具介绍测试
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值