codeforce Gym 100418K Cards (概率,数学)

麦田故事的最优策略
本文探讨了在特定条件下的牌局策略问题,通过数学计算找出最有可能获得最大牌的x值,适用于对概率和策略感兴趣的技术人员。

题意:麦田的故事,n张牌,取x张牌,记住前x张牌最大的值m,继续往后取,遇到第一张比m大的牌就停下来。求一个x使得最后的牌在整副牌里是最大的期望最大。

假设最大的牌是A,A在各种位置出现的概率就是相等的,因为题目不要求输出概率,所以当成1。在A固定的情况下,在它前面的牌中最大的牌B,出现在各个位置的概率也是相等的,计算一下各个事件的概率。

当X固定的时候,B出现在它前面的事件概率和就是成功的概率,所以问题就转化成了求一个X,使得下面这个矩形框中的概率和最大。

样例,n=5

 并不需要用组合数打表算概率

#include<bits/stdc++.h>

int main()
{
    int n;scanf("%d",&n);
    int X = 0;
    double E = 1./n;
    for(int x = 1; x < n; x++){
        double e = 1;
        for(int j = x+1; j < n; j++)
            e += x*1.0/j;
        if(e>E) { X = x; E = e; }
    }
    printf("%d\n",X);
    return 0;
}

 

 

转载于:https://www.cnblogs.com/jerryRey/p/4712319.html

### Codeforces Problem or Contest 998 Information For the specific details on Codeforces problem or contest numbered 998, direct references were not provided within the available citations. However, based on similar structures observed in other contests such as those described where configurations often include constraints like `n` representing numbers of elements with defined ranges[^1], it can be inferred that contest or problem 998 would follow a comparable format. Typically, each Codeforces contest includes several problems labeled from A to F or beyond depending on the round size. Each problem comes with its own set of rules, input/output formats, and constraint descriptions. For instance, some problems specify conditions involving integer inputs for calculations or logical deductions, while others might involve more complex algorithms or data processing tasks[^3]. To find detailed information regarding contest or problem 998 specifically: - Visit the official Codeforces website. - Navigate through past contests until reaching contest 998. - Review individual problem statements under this contest for precise requirements and examples. Additionally, competitive programming platforms usually provide comprehensive documentation alongside community discussions which serve valuable resources when exploring particular challenges or learning algorithmic solutions[^2]. ```cpp // Example C++ code snippet demonstrating how contestants interact with input/output during competitions #include <iostream> using namespace std; int main() { int n; cin >> n; // Process according to problem statement specifics } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值