杭电1203-- I NEED A OFFER!

题目描述:
这里写图片描述

思路:
这道题与2955思想相同,只不过更直观:求不被录取的最小概率
代码:

#include<stdio.h>
#include<string.h>
#define MAXN 10005
float MIN(float a,float b)
{
    return a<b?a:b;
}
int main()
{
    int i,j,max,n,m;
    int a[MAXN];
    float b[MAXN],dp[MAXN],p;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        if(m==0&&n==0) break;
        for(i=1;i<=n;i++) dp[i]=1;
        for(i=1;i<=m;i++)
        {
            scanf("%d %f",&a[i],&b[i]);//cnt+=a[i];
            b[i]=1-b[i];//求不被录取的概率 
        }
        dp[0]=1;    //没钱不被录取的概率是1 
        for(i=1;i<=m;i++)
        {
            for(j=n;j>=a[i];j--)
            dp[j]=MIN(dp[j],dp[j-a[i]]*b[i]);
        }
        printf("%.1f%%\n",(1-dp[n])*100);
    }
    return 0;
}
<?xml version="1.0"?> <package format="2"> <name>self_msgs_and_srvs</name> <version>0.0.0</version> <description>The self_msgs_and_srvs package</description> <!-- One maintainer tag required, multiple allowed, one person per tag --> <!-- Example: --> <!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> --> <maintainer email="kyle@todo.todo">kyle</maintainer> <!-- One license tag required, multiple allowed, one license per tag --> <!-- Commonly used license strings: --> <!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 --> <license>TODO</license> <!-- Url tags are optional, but multiple are allowed, one per tag --> <!-- Optional attribute type can be: website, bugtracker, or repository --> <!-- Example: --> <!-- <url type="website">http://wiki.ros.org/self_msgs_and_srvs</url> --> <!-- Author tags are optional, multiple are allowed, one per tag --> <!-- Authors do not have to be maintainers, but could be --> <!-- Example: --> <!-- <author email="jane.doe@example.com">Jane Doe</author> --> <!-- The *depend tags are used to specify dependencies --> <!-- Dependencies can be catkin packages or system dependencies --> <!-- Examples: --> <!-- Use depend as a shortcut for packages that are both build and exec dependencies --> <!-- <depend>roscpp</depend> --> <!-- Note that this is equivalent to the following: --> <!-- <build_depend>roscpp</build_depend> --> <!-- <exec_depend>roscpp</exec_depend> --> <!-- Use build_depend for packages you need at compile time: --> <!-- <build_depend>message_generation</build_depend> --> <!-- Use build_export_depend for packages you need in order to build against this package: --> <!-- <build_export_depend>message_generation</build_export_depend> --> <!-- Use buildtool_depend for build tool packages: --> <!-- <buildtool_depend>catkin</buildtool_depend> --> <!-- Use exec_depend for packages you need at runtime: --> <!-- <exec_depend>message_runtime</exec_depend> --> <!-- Use test_depend for packages you need only for testing: --> <!-- <test_depend>gtest</test_depend> --> <!-- Use doc_depend for packages you need only for building documentation: --> <!-- <doc_depend>doxygen</doc_depend> --> <buildtool_depend>catkin</buildtool_depend> <build_depend>message_generation</build_depend> <depend>std_msgs</depend> <exec_depend>message_runtime</exec_depend> <!-- The export tag contains other, unspecified, tags --> <export> <!-- Other tools can request additional information be placed here --> </export> </package> 注释上述代码
最新发布
09-09
<think> 我们正在注释一个ROS package.xml文件,针对自定义消息和服务包(self_msgs_and_srvs)进行详细说明。 注意:保留原始注释,添加中文注释说明每个标签的作用和注意事项。 特别关注依赖关系:buildtool_depend, build_depend, depend, exec_depend等。 同时,注意维护者、许可证等元数据字段的注释说明。 最后,按照要求输出3-5个相关问题。 </think> 以下是完整注释的`self_msgs_and_srvs`包的`package.xml`文件,特别针对ROS自定义消息和服务的开发场景: ```xml <?xml version="1.0"?> <!-- XML声明,指定文档使用XML 1.0标准 --> <package format="2"> <!-- 包配置文件,符合ROS package.xml格式版本2 --> <!-- ========== 基础元数据 ========== --> <name>self_msgs_and_srvs</name> <!-- 包名称(必需标识符),用于消息/服务通信 --> <version>0.0.0</version> <!-- 开发阶段版本号(建议发布前更新) --> <description>The self_msgs_and_srvs package</description> <!-- 包功能描述:存放自定义消息类型和服务定义 --> <!-- ========== 维护者信息 ========== --> <!-- (保留原始注释) 至少需要一个maintainer标签 --> <maintainer email="kyle@todo.todo">kyle</maintainer> <!-- 维护者邮箱需替换为真实地址 --> <!-- ========== 许可证信息 ========== --> <!-- (保留原始注释) 必须指定许可证类型 --> <license>TODO</license> <!-- 占位符,实际需替换为BSD/MIT等有效许可证 --> <!-- ========== 相关链接 ========== --> <!-- (保留原始注释) 可添加文档/wiki/仓库链接 --> <!-- 示例:<url type="repository">https://github.com/...</url> --> <!-- ========== 作者信息 ========== --> <!-- (保留原始注释) 可添加多个作者 --> <!-- 示例:<author email="contributor@example.com">贡献者姓名</author> --> <!-- ========== 依赖管理 ========== --> <!-- (保留原始注释) 详细说明各种依赖标签用途 --> <buildtool_depend>catkin</buildtool_depend> <!-- 核心编译工具依赖(必须) --> <build_depend>message_generation</build_depend> <!-- 编译时依赖:消息生成工具 --> <depend>std_msgs</depend> <!-- 双重依赖:编译和运行时都需要标准消息库 --> <exec_depend>message_runtime</exec_depend> <!-- 运行时依赖:消息解析支持 --> <!-- ===== 建议添加的依赖示例 ===== --> <!-- <test_depend>gtest</test_depend> 单元测试框架 --> <!-- <doc_depend>doxygen</doc_depend> 文档生成工具 --> <!-- ========== 扩展配置区 ========== --> <export> <!-- 元数据导出区,用于插件或接口声明 --> <!-- 自定义消息包通常在此声明消息类型 --> <!-- 示例:<message_generator plugin="${prefix}/msg/MyMessage.xml"/> --> </export> </package> ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值