codeforces 1599 C. Bubble Strike

题意

Little Johnny Bubbles enjoys spending hours in front of his computer playing video games. His favorite game is Bubble Strike, fast-paced bubble shooting online game for two players.

Each game is set in one of the N maps, each having different terrain configuration. First phase of each game decides on which map the game will be played. The game system randomly selects three maps and shows them to the players. Each player must pick one of those three maps to be discarded. The game system then randomly selects one of the maps that were not picked by any of the players and starts the game.

Johnny is deeply enthusiastic about the game and wants to spend some time studying maps, thus increasing chances to win games played on those maps. However, he also needs to do his homework, so he does not have time to study all the maps. That is why he asked himself the following question: "What is the minimum number of maps I have to study, so that the probability to play one of those maps is at least P"?

Can you help Johnny find the answer for this question? You can assume Johnny's opponents do not know him, and they will randomly pick maps.

思路

首先n只有1000
当然肯定是看的地图越多越有把握达到p的概率
所以就是暴力做法
一个一个涂色,当然可以二分,这里数剧太小就直接O(3e3)
对于每一局,如果恰好是一个熟悉的地图都没有,那么增加的概率必是0
如果恰好认识一个地图,那么选择另一个不认识的淘汰,有1/2的概率
如果恰好认识两个地图,那么选择另一个不认识的淘汰,必选中熟悉地图
如果三个地图,必选中熟悉地图
这就像高中的超几何分布吧

AC

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;//1e3
double p;//0~1

int C(int x, int t)//Cx^t
{
    ll ret = 1;
    for (int i = 1; i <= t; i++)
        ret *= x - i + 1;
    for (int i = 1; i <= t; i++)
        ret /= i;
    return ret;
}

int main()
{
    cin >> n >> p;
    for (int i = 0; i <= n; i++)
    {
        double ans = 0;
        for (int j = 1; j <= 3; j++)
        {
            int res = C(i, j) * C(n - i, 3 - j);
            if (j == 1)
                ans += res * 0.5;
            if (j >= 2)
                ans += res;
        }
        ans /= C(n, 3);
        if (ans >= p)
            return cout << i << endl, 0;
    }
    return 0;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

.0-0.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值