Namomo Summer Camp 2023 Day 1 题解 | JorbanS

A - Amusement Arcade

#include <iostream>
#include <map>

using namespace std;
typedef long long ll;

void solve() {
    map<ll, bool> mp;
    for (int i = 0; i < 63; i ++) mp[1ll << i] = true;
    ll n; cin >> n;
    if (n == 1 || mp[n - 1]) {
        cout << 1 << endl;
        return;
    }
    for (int i = 0; (1ll << i) <= n / 2; i ++) {
        ll j = n - (1ll << i) - 1;
        if (mp[j]) {
            cout << (1ll << i) + 1 << endl;
            return;
        }
    }
    cout << "impossible" << endl;
}

int main() {
    solve();
    return 0;
}

B - Brexiting and Brentering

#include <iostream>

using namespace std;
string ss = "aeiou";

void solve() {
    string s; cin >> s;
    int n = s.size();
    for (int i = n - 1; i >= 0; i --)
        for (int j = 0; j < ss.size(); j ++)
            if (s[i] == ss[j]) {
                for (int k = 0; k <= i; k ++) cout << s[k];
                cout << "ntry";
                return;
            }
}

int main() {
    solve();
    return 0;
}

I - Monty’s Hall

蒙提霍尔问题(三门问题),尽可能要换掉第一次选的门

我是看剧看到的,韩国 D.P. 🤔🤔🤔🤣🤣🤣

出自美国的电视游戏节目Let’s Make a Deal。问题名字来自该节目的主持人蒙提·霍尔(Monty Hall)。参赛者会看见三扇关闭了的门,其中一扇的后面有一辆汽车,选中后面有车的那扇门可赢得该汽车,另外两扇门后面则各藏有一只山羊。当参赛者选定了一扇门,但未去开启它的时候,节目主持人开启剩下两扇门的其中一扇,露出其中一只山羊。主持人其后会问参赛者要不要换另一扇仍然关上的门。问题是:换另一扇门会否增加参赛者赢得汽车的机率。如果严格按照上述的条件,那么答案是会。不换门的话,赢得汽车的几率是1/3。换门的话,赢得汽车的几率是2/3。虽然该问题的答案在逻辑上并不自相矛盾,但十分违反直觉。

#include <iostream>

using namespace std;

double solve() {
    double d, s, e; cin >> d >> s >> e;
    double p = s / d;
    double res = 0;
    double last = d - s - e;
    if (last >= s) {
        res += p * 0;
        res += (1 - p) * s / last;
    } else {
        int t = s - last;
        res += p * t / s;
        res += (1 - p) * 1;
    }
    return res;
}

int main() {
    printf("%.8lf\n", solve());
    return 0;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

JorbanS

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

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

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

打赏作者

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

抵扣说明:

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

余额充值