• Namomo Summer Camp 2023 Day 1 题解 | JorbanS


    A - Amusement Arcade

    #include 
    #include 
    
    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;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28

    B - Brexiting and Brentering

    #include 
    
    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;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    I - Monty’s Hall

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

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

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

    #include 
    
    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
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
  • 相关阅读:
    DXP TreeList 目录树
    【Html——自由小球球】(效果+代码)
    蓝桥杯每日一题2023.11.21
    大数据时代下,医疗行业如何实现数据安全保障?
    海藻酸钠-四嗪|TZ-PEG-alginate|海藻酸钠-peg-四嗪TZ
    【学习笔记】杜教筛
    《前端运维》一、Linux基础--05Shell运算符
    ADB 命令结合 Monkey 的使用
    SpringBoot+Vue实现前后端分离的在线考试报名系统
    Java——list的四种遍历
  • 原文地址:https://blog.csdn.net/qq_40179418/article/details/133843450