hdu5045 Contest 状压DP

使用CubeMX生成的项目在Keil下添加DSP库并包含arm_math头文件后报错的解决办法 问题描述: 最近使用Cube生成工程后,在Keil中使用Manage Runtime Environment即绿色小饼干按钮添加CMSIS的DSP库后编译报错。很有意思的是,STM32论坛上有外国朋友报告的同样的错误,都是30个Errors,5个Warning。 问题分析: 参考国内论坛某帖子(具体想不起来了),认为因该是Cube复制了库后,Keil从原始Packs目录下引用DSP库导致和Cub... 阅读详情

Contest

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1669    Accepted Submission(s): 669


Problem Description
In the ACM International Collegiate Programming Contest, each team consist of three students. And the teams are given 5 hours to solve between 8 and 12 programming problems. 

On Mars, there is programming contest, too. Each team consist of N students. The teams are given M hours to solve M programming problems. Each team can use only one computer, but they can’t cooperate to solve a problem. At the beginning of the ith hour, they will get the ith programming problem. They must choose a student to solve this problem and others go out to have a rest. The chosen student will spend an hour time to program this problem. At the end of this hour, he must submit his program. This program is then run on test data and can’t modify any more. 

Now, you have to help a team to find a strategy to maximize the expected number of correctly solved problems. 

For each problem, each student has a certain probability that correct solve. If the ith student solve the jth problem, the probability of correct solve is Pij .

At any time, the different between any two students’ programming time is not more than 1 hour. For example, if there are 3 students and there are 5 problems. The strategy {1,2,3,1,2}, {1,3,2,2,3} or {2,1,3,3,1} are all legal. But {1,1,3,2,3},{3,1,3,1,2} and {1,2,3,1,1} are all illegal. 

You should find a strategy to maximize the expected number of correctly solved problems, if you have know all probability
 

Input
The first line of the input is T (1 ≤ T ≤ 20), which stands for the number of test cases you need to solve.

The first line of each case contains two integers N ,M (1 ≤ N ≤ 10,1 ≤ M ≤ 1000),denoting the number of students and programming problem, respectively.

The next N lines, each lines contains M real numbers between 0 and 1 , the jth number in the ith line is Pij .
 

Output
For each test case, print a line “Case #t: ”(without quotes, t means the index of the test case) at the beginning. Then a single real number means the maximal expected number of correctly solved problems if this team follow the best strategy, to five digits after the decimal point. Look at the output for sample input for details.
 

Sample Input
1 2 3 0.6 0.3 0.4 0.3 0.7 0.9
 

Sample Output
Case #1: 2.20000
 


发现其实每个人的做题情况的要求,具有模2的性质,即不能比别人多做两道题,可以用二进制串进行状态压缩,使用一个长度为n的二进制串,每一位表示到当前为止那个人相对于上一轮是否做过题,如果他已经做过一次了,就暂时不再让他做,再让他做就会出现例如100201的情况,做2个题的人比做0个题的人要多做两个题,这里说的0,1,2都是相对于上一轮的,并不是绝对的数量


dp[i][t]为做到第i个题,人的做题状况为t时达到的最大概率和


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

double dp[1005][10005];
double p[15][1005];

int n, m, T, kase;

int main()
{
	cin >> T;
	kase = 0;
	while (T--) {
		scanf("%d%d", &n, &m);
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				scanf("%lf", &p[i][j]);
			}
		}
		int lim = (1 << n) - 1;
		for (int i = 0; i <= m; i++) {
			for (int j = 0; j <= lim; j++) {
				dp[i][j] = -1.0;   //标记不不可能存在的状态为-1
			}
		}
		//for (int i = 0; i <= lim; i++) dp[0][i] = 0; //debug
		dp[0][0] = 0.0;
		for (int i = 1; i <= m; i++) {  //每个题
			for (int k = 0; k <= lim; k++) {  //到前一道题为止每个人的答题状况
				if (dp[i - 1][k] < 0.0) continue; //debug 前一种状态不存在,继续遍历查找
				for (int j = 0; j < n; j++) { //每个人
					int t = (1 << j);
					if (!(t & k)) {
						t = t | k;  //做这个题,更新做题状况
						if (t == lim) t = 0;  //每个人都做了一道题,重新开始轮
						dp[i][t] = max(dp[i][t], dp[i - 1][k] + p[j + 1][i]);
					}
				}
			}
		}
		double ans = 0.0;
		for (int i = 0; i <= lim; i++) {
			ans = max(ans, dp[m][i]);
		}
		printf("Case #%d: %.5f\n", ++kase, ans);
	}
	return 0;
}


Zemax操作--2(单透镜和双胶合透镜优化) 单透镜 要求 镜头数据里面的数量变化后要重新设计优化函数 设计 一、初始参数 按照要求输入波长、入瞳孔径、视场数据编辑器如图 物面--透镜前表面--透镜后表面--相面(镜头数据再插入一个面如图) 将2面曲率半径F数设置为10,zemax自动给出合适值 设置面2的边缘光线高度,zemax自动给出合适值 二、评价参数设置 将面1曲率半径设置为变量 再设置评价函数告诉zemax我们需要什么条件,评价函数默认即可 执行优化 双胶合透镜 要求 ... 阅读详情

相关推荐

告别配置烦恼!保姆级教程:在Windows 10/11上为QT5.14.2配置MSVC2017编译器(附VS2022组件避坑指南)

本文提供了一份详细的保姆级教程,指导如何在Windows 10/11上为QT5.14.2配置MSVC2017编译器,包括VS2022组件避坑指南。从环境准备到关键配置,再到调试工具验证和Qt Creator中的编译器设置,一步步解决常见问题,帮助开发者快速搭建稳定可靠的开发环境。

weixin_30615767的博客 504

[状压dp]HDU5045 Contest

题意: n和人做m道题, 每俩人做的题数不能相差一题以上.(也就是每n道题分别由n个人完成) 给n个人分别做m道题的概率, 求完成m题的最大期望 $1\le N \le 10$ 注意!!! fill dp 的地方! [0, m] 所以要 m+1 !! 1 #include <cstdio> 2 #include <cstdlib> ...

aicheng4794的博客 129

招标信息爬取工具

一个能帮你节省大量时间的实用小工具,我自己用了挺久,分享出来给有需要的朋友

qq_56877290的博客 849

【DP】 HDU 5045 Contest 状压

必须按照循序写题 所以要给dp数组赋初值-1 每取满n个时要注意要使得now为零 以便下次取 #include #include #include #include #include #include #include #include using namespace std; #include #include #include #include #include

Kewowlo 1378

Elsevier期刊LaTeX双栏模板(cas-dc)实战:从Overleaf配置到投稿全流程

本文详细介绍了Elsevier期刊LaTeX双栏模板(cas-dc)在Overleaf平台上的配置与使用全流程,包括模板结构解析、标题与作者信息规范、摘要与关键词特殊格式、正文写作技巧、参考文献管理以及投稿前检查清单。特别针对Elsevier期刊投稿需求,提供了从模板安装到最终投稿的实用指南,帮助研究者高效完成论文排版工作。

weixin_28455801的博客 1336

汇川PLC和PLC之间ModebusTCP通讯

然后在全局变量中创建相应的变量关联IW和QW的寄存器创建全部变量//AM402作为主站——读H3U(D12-D21)//AM402作为主站——写给H3U(D200-D209)或者使用数组的方式。

panjinliang066333的博客 3万+

hdu 5045 Contest (状压DP)

状压dp,将m道题分段,每段有ndao

FirstorLoser 412

解锁Jetbrains AI助手:中国开发者实战配置与效率跃迁指南

本文为中国开发者提供了一份详细的Jetbrains AI助手实战配置指南。针对服务地域限制,核心解决方案是通过修改Jetbrains账户区域信息并配置网络代理,实现插件的稳定启用。文章进一步分享了AI助手在解读遗留代码、生成中文提交信息、智能问答等场景下的具体应用,旨在帮助开发者深度集成这一工具,实现编码生产力的显著提升。

weixin_28832121的博客 592

HDU 5045 Contest(状压DP或费用流)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5045 题意:N个人去做M道题,给出这N个人解这M道题的概率,且任意两人做题数不能相差1,问做出所有题的最大期望 思路:因为做题数不超过1的限制,这相当于是以N个人为一轮做N道题,做完M道为止,故而可以用dp[i][j]代表解决前i道题时状态为j,当j == (1 << n)...

Tongqi 538

PCL 基于法向距离的对应点获取

提出了一种基于法向量欧氏距离的点云配准方法。详细推导了法向量距离计算公式,并给出具体计算流程。在代码实现部分,采用PCL库完成了点云法向量计算和对应关系估计,通过可视化验证了算法有效性。实验结果表明,该方法能够准确获取点云间的对应关系,为后续点云配准奠定了基础。

点云侠的博客 228

Python爬虫:爬取健身平台运动数据(跑步、骑行轨迹)

通过分析这些运动数据,用户能够了解自己的运动趋势、运动成绩,并作出相应的调整。通过使用Strava的API,我们成功地获取了用户的运动活动信息和运动轨迹数据,并进行了存储与可视化。Strava的API提供了丰富的数据接口,能够通过OAuth2认证获取用户的运动数据,包括历史数据、运动轨迹等信息。Strava的API还提供了获取活动轨迹数据的接口,返回的数据格式通常是GeoJSON格式,适用于地图可视化。随着大数据技术的发展,运动数据的分析和可视化为个人健康管理、运动训练计划的优化等提供了强大的支持。

2201_76125261的博客 1085

hdu5045 Contest 状压dp/KM

链接:http://acm.hdu.edu.cn/showproblem.php?pid=5045 Contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 260    Accepted Submission(s): 1

833

Triton server的部署、构建、backend插件机制代码梳理、模型加载、自定义C++backend流程

Triton inference server的部署、构建、backend机制代码详细梳理、模型加载过程、自定义C++backend流程.

C/C++、嵌入式开发、深度学习算法、模型部署与推理优化 479

HDU-5045 Contest(状压DP)

HDU-5045 Contest 一、题目原文 In the ACM International Collegiate Programming Contest, each team consist of three students. And the teams are given 5 hours to solve between 8 and 12 programming problems.

Summer_via的博客 420

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

hdu 5045 Contest(状压DP)

ContestTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2143    Accepted Submission(s): 878Problem DescriptionIn the ACM International Collegiate...

Timeclimber 273

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

HDU5045-Contest(状压dp)

题意: 有n个学生,m道题,给出每个同学解出m个问题的概率,在解题过程中每个学生的解题数的差不大于1,求最大能解出题目数的期望 分析: n很小,知道用状压,但是比赛没做出来(脑子太死了,有一个限制条件在解题过程中每个学生的解题数的差不大于1,哎,关键在这句话,那就是说,在解题过程中必须先是每人解出一道题目,才能继续解题,那就是状态全部是1时处理成全部是0) dp[i][j]表示前i个题目解...

weixin_30535167的博客 103

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

HDU 5045 Contest(状压DP)

Problem Description In the ACM International Collegiate Programming Contest, each team consist of three students. And the teams are given 5 hours to solve between 8 and 12 programming pr...

weixin_30455067的博客 130

HDU - 5045 Contest(DP+状压)

Problem Description In the ACM International Collegiate Programming Contest, each team consist of three students. And the teams are given 5 hours to solve between 8 and 12 programming problems. 

那些年 1214

HDU 5045 Contest(状压DP或DFS)

此题一开始就看了。。又把题意看错,我以为是随便选。感觉压力巨大

glq007的acm的奋斗 815

HDU5045:Contest(状压dp)

reference:http://blog.csdn.net/stay_accept/article/details/51232891 Contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1759    Accept

junior19的博客 273

HDU 5045 Contest 期望+状压dp 2014 ACM/ICPC Asia Regional Shanghai Online

题意: 给定n个人 m个题目 下面n*m的矩阵表示每个人解出每道题的概率 我们可以得到一个模长为m的集合{1,2,3,1,2} 代表每道题是谁解出的。 有众多集合,且获得这个集合有一个期望,求期望最大的那个集合 ( 的期望值是多少) 一个限制: 对于集合 {1,1,2,3,1} 这样是不合法的(即从[1,n]题必须是1-n的排列,然后[n+1, 2n]题也是一个排列) 然后状

九野的博客 1693

HDU - 5045 2014 ACM/ICPC Asia Regional Shanghai Online D - Contest (状压DP)

Contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1820    Accepted Submission(s): 735 Problem Description In the ACM Internationa

WhaleFall 379

HDU 5045 - Contest(dp + 状压)

Problem Description In the ACM International Collegiate Programming Contest, each team consist of three students. And the teams are given 5 hours to solve between 8 and 12 programming problems.

Halo 603

Hdu 5045 Contest (状态压缩dp)

Hdu 5045 Contest (状态压缩dp)  题意:有N个同学共同解决M道问题,每道题只能由一个同学来解决,每次花费一分钟,并且有成功率P,不能再次修改答案,任何时候不能任意两个同学做的题目数目不能相差超过1道题,有多种策略,求所有策略里最大成功期望是多少?     分析:最优化问题,用动态规划解决,由题意,每次做题时每个人都要轮到一次,然后状态清零,用二进制表示状态,即 0000

归去,也无风雨也无晴 307

HDU5045Contest(记忆化搜索)

HDU5045Contest(记忆化搜索) 题目链接 题目大意:有N个人组成一支队伍来答题,每一个人答每道题的正确率都是已知的,可是有个要求:一直每一个人答不论什么一道题目的时间都是1个小时,要求在不论什么时刻,不论什么两个人的答题累计时间都不能超过1.求这样答题的最优策略下最好的出题期望。 解题思路:把全部的人答题的累计时间作为状态。用二进制数来表示。当这...

adr5970的博客 156

hdu 5045 Contest(dp)

题目链接:hdu 5045 Contest 题目大意:一个队伍有N个人,比赛一共有M道题目,给定一个矩阵,表示每个人答对相应题目的正确率。现在对于每道题,可以派出一名学生参加答题,但是在任意时刻,任意两个学生答题数量不能相差2题以上。 解题思路:dp[i][s],表示在第i道题,s表示一个二进制状态,表示哪些人答过题(相应的),2N−1=0 #include #include #

不慌不忙、不急不躁 1018
上一篇: hdu5047 Sawtooth 规律 + JAVA大数
下一篇: hdu4764 Stone 巴什博弈
Daemoonn
博客等级 码龄11年 42粉丝 198原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址