1 条题解

  • 0
    @ 2025-10-28 17:07:09
    #include <iostream>
    #include <cstring>
    using namespace std;
    int main()
    {
        int ans = 0, size;
        string str;
        cin >> str;
        size = str.size();
        for (int i = 0; i < size; i++)
        {
            if (str[i] == 'a')
            {
                if (i != size - 1)
                {
                    if (str[i + 1] == 'c')
                    {
                        ans += 2;
                        i++;
                    }
                    else if (str[i + 1] == 'b')
                    {
                        ans += 5;
                        i++;
                    }
                    else
                    {
                        ans++;
                    }
                }
                else
                {
                    ans += 1;
                }
            }
            else if (str[i] == 'b')
            {
                ans += 2;
            }
            else if (str[i] == 'c')
            {
                ans += 3;
            }
            else if (str[i] == 'd')
            {
                ans += 4;
            }
        }
        cout << ans << endl;
        return 0;
    }
    
    • 1

    信息

    ID
    500
    时间
    1000ms
    内存
    256MiB
    难度
    1
    标签
    (无)
    递交数
    95
    已通过
    21
    上传者