1 条题解

  • -1
    @ 2024-8-2 16:19:45

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
        string s, x;
        cin >> s;
    
        int cnt = 0, ans = 0, t = 1;
    
        while (true) {
            cin >> x;
            cnt++;
    
            if (cnt > 3) {
                ans += t; // 尝试次数>3,算时间
                t *= 2;
            }
    
            // 尝试成功
            if (x == s) {
                cout << ans;
                return 0;
            }
    
            // 尝试到 10 次不成功
            if (cnt == 10) {
                cout << "The end";
                return 0;
            }
        }
    
        // This line is unreachable and can be removed
        // return 8;
    }
    
    

    信息

    ID
    1027
    时间
    1000ms
    内存
    128MiB
    难度
    10
    标签
    递交数
    4
    已通过
    2
    上传者