POJ 2151 Check the difficulty of problems(概率dp)

本文介绍了一种解决特定类型竞赛编程问题的方法,该问题涉及计算每个团队至少解决一个问题且冠军团队至少解决一定数量问题的概率。文章提供了一个示例代码,详细展示了如何通过动态规划来求解此类问题。

Language:
Check the difficulty of problems
Time Limit: 2000MS Memory Limit: 65536K
Total Submissions: 5419 Accepted: 2384

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

Source

POJ Monthly,鲁小石


题意: n个人,m道题,求每个人做出题,并且至少一个做出k道题的概率

思路:等于每个人做出题的概率--每个人做出题并且没有一个人做出k到题的概率


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>


#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define MID(x,y) ((x+y)>>1)

#define eps 1e-8
typedef __int64 ll;

#define fre(i,a,b)  for(i = a; i < b; i++)
#define free(i,b,a) for(i = b; i >= a;i--)
#define mem(t, v)   memset ((t) , v, sizeof(t))
#define ssf(n)      scanf("%s", n)
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pf          printf
#define bug         pf("Hi\n")

using namespace std;

#define INF 0x3f3f3f3f
#define N 1005

double dp[N][35][35];  // dp[i][j][k]  第 i 个人 前 j 道题 做 k 道概率
double p[N][35];
int n,m,k;

void solve()
{
	int i,j,t;
	mem(dp,0);

    fre(i,1,n+1)         //初始每一个人第一道题 对 与不对
      {
      	dp[i][1][0]=1-p[i][1];
		dp[i][1][1]=p[i][1];
      }

	fre(i,1,n+1)         //每一个人m到题都没有作对
	 {
	 	fre(j,2,m+1)
		  dp[i][j][0]=dp[i][j-1][0]*(1-p[i][j]);
	 }

	fre(i,1,n+1)        //每一个人j道题 做t道概率
	 fre(j,2,m+1)
	  fre(t,1,j+1)
	 {
       if(t<j)
		 dp[i][j][t]=dp[i][j-1][t]*(1-p[i][j])+dp[i][j-1][t-1]*p[i][j];
	   else
	     dp[i][j][t]=dp[i][j-1][t-1]*p[i][j];
	 }

	 double p1=1,p2;

	 fre(i,1,n+1)
	    p1*=(1-dp[i][m][0]);    //每个人都做出提的概率

	 p2=1;

	 fre(i,1,n+1)
	  {
	  	 double te=0;
	  	 fre(j,1,k)
	  	   te+=dp[i][m][j];
		 p2*=te;            //每个人做出题但是没有一个做了k道题的概率
	  }

	pf("%.3lf\n",p1-p2);
}

int main()
{
	int i,j;
	while(~sfff(m,n,k),n+m+k)
	{
		fre(i,1,n+1)
		   fre(j,1,m+1)
		     scanf("%lf",&p[i][j]);
	   solve();
	}
    return 0;
}


C语言-光伏MPPT算法:电导增量法扰动观察法+自动全局搜索Plecs最大功率跟踪算法仿真内容概要:本文档主要介绍了一种基于C语言实现的光伏最大功率点跟踪(MPPT)算法,结合电导增量法与扰动观察法,并引入自动全局搜索策略,利用Plecs仿真工具对算法进行建模与仿真验证。文档重点阐述了两种经典MPPT算法的原理、优缺点及其在不同光照和温度条件下的动态响应特性,同时提出一种改进的复合控制策略以提升系统在复杂环境下的跟踪精度与稳定性。通过仿真结果对比分析,验证了所提方法在快速性和准确性方面的优势,适用于光伏发电系统的高效能量转换控制。; 适合人群:具备一定C语言编程基础和电力电子知识背景,从事光伏系统开发、嵌入式控制或新能源技术研发的工程师及高校研究人员;工作年限1-3年的初级至中级研发人员尤为适合。; 使用场景及目标:①掌握电导增量法与扰动观察法在实际光伏系统中的实现机制与切换逻辑;②学习如何在Plecs中搭建MPPT控制系统仿真模型;③实现自动全局搜索以避免传统算法陷入局部峰值问题,提升复杂工况下的最大功率追踪效率;④为光伏逆变器或太阳能充电控制器的算法开发提供技术参考与实现范例。; 阅读建议:建议读者结合文中提供的C语言算法逻辑与Plecs仿真模型同步学习,重点关注算法判断条件、步长调节策略及仿真参数设置。在理解基本原理的基础上,可通过修改光照强度、温度变化曲线等外部扰动因素,进一步测试算法鲁棒性,并尝试将其移植到实际嵌入式平台进行实验验证。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值