LightOJ 1265 Island of Survival【概率】

在一个仅存老虎、鹿及一名参赛者的荒岛上,每日发生不同生物间的随机相遇。本文通过数学建模探讨了参赛者如何通过策略最大化其生存概率,并给出了解决方案。

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

参看资料:

https://blog.youkuaiyun.com/dllpXFire/article/details/81186064


题目:

You are in a reality show, and the show is way too real that they threw into an island. Only two kinds of animals are in the island, the tigers and the deer. Though unfortunate but the truth is that, each day exactly two animals meet each other. So, the outcomes are one of the following

a)      If you and a tiger meet, the tiger will surely kill you.

b)      If a tiger and a deer meet, the tiger will eat the deer.

c)      If two deer meet, nothing happens.

d)      If you meet a deer, you may or may not kill the deer (depends on you).

e)      If two tigers meet, they will fight each other till death. So, both will be killed.

If in some day you are sure that you will not be killed, you leave the island immediately and thus win the reality show. And you can assume that two animals in each day are chosen uniformly at random from the set of living creatures in the island (including you).

Now you want to find the expected probability of you winning the game. Since in outcome (d), you can make your own decision, you want to maximize the probability.

Input

Input starts with an integer T (≤ 200), denoting the number of test cases.

Each case starts with a line containing two integers t (0 ≤ t ≤ 1000)and d (0 ≤ d ≤ 1000) where t denotes the number of tigers and ddenotes the number of deer.

Output

For each case, print the case number and the expected probability. Errors less than 10-6 will be ignored.

Sample Input

4

0 0

1 7

2 0

0 10

Sample Output

Case 1: 1

Case 2: 0

Case 3: 0.3333333333

Case 4: 1

题目大意: 

       一个森林里面有多只老虎,多只老虎,1个人,每天至少有两个生物碰面:老虎与老虎,都over;老虎与人,人over;老虎与鹿,鹿over;鹿与人,擦肩而过。问最后人活下来的概率。

解题思路:

       该题最后求的结果与天数无关,而与老虎的数目有关;当老虎为奇数时,最后总会剩余一直老虎,人存活的概率为0;当老虎的数目为奇数时,一直选两只老虎虎咬虎,求人最后剩下的概率。是的,和鹿的数目没有关系。

实现代码:

#include<iostream>
#include<cstdio>
using namespace std;

int main(){
    int t,n,m;
    scanf("%d",&t);

    for(int k=1;k<=t;k++){
        scanf("%d%d",&n,&m);
        double ans=1;
        if(n%2==0){
            while(n!=0){
                ans*=(n-1)*1.0/(n+1);
                n-=2;
            }
        }else{
            ans=0;
        }
        printf("Case %d: %lf\n",k,ans);
    }
    return 0;
}
内容概要:本文档详细介绍了基于MATLAB实现多目标差分进化(MODE)算法进行无人机三维路径规划的项目实例。项目旨在提升无人机在复杂三维环境中路径规划的精度、实时性、多目标协调处理能力、障碍物避让能力和路径平滑性。通过引入多目标差分进化算法,项目解决了传统路径规划算法在动态环境和多目标优化中的不足,实现了路径长度、飞行安全距离、能耗等多个目标的协调优化。文档涵盖了环境建模、路径编码、多目标优化策略、障碍物检测与避让、路径平滑处理等关键技术模块,并提供了部分MATLAB代码示例。 适合人群:具备一定编程基础,对无人机路径规划和多目标优化算法感兴趣的科研人员、工程师和研究生。 使用场景及目标:①适用于无人机在军事侦察、环境监测、灾害救援、物流运输、城市管理等领域的三维路径规划;②通过多目标差分进化算法,优化路径长度、飞行安全距离、能耗等多目标,提升无人机任务执行效率和安全性;③解决动态环境变化、实时路径调整和复杂障碍物避让等问题。 其他说明:项目采用模块化设计,便于集成不同的优化目标和动态环境因素,支持后续算法升级与功能扩展。通过系统实现和仿真实验验证,项目不仅提升了理论研究的实用价值,还为无人机智能自主飞行提供了技术基础。文档提供了详细的代码示例,有助于读者深入理解和实践该项目。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值