• 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
  • 相关阅读:
    Linux服务健康检查,自动启动(crontab)
    gitlab数据备份和恢复
    MySQL基础篇总结
    alginate-FITC 海藻酸钠-异硫氰基荧光素 FITC-peg-海藻酸钠
    arcgis地形分析全流程
    navicat 导入dmp文件
    MySQL高级八:SQL执行流程
    mOFDM系统下对比SC算法,Minn算法,PARK算法同步性能matlab仿真分析
    stm32项目平衡车详解(stm32F407)上
    基于BP神经网络进行手写体识别(Matlab代码实现)
  • 原文地址:https://blog.csdn.net/qq_40179418/article/details/133843450