#1594. 珅泽教育CSP-J第一轮模拟考第四套 第 33 题

珅泽教育CSP-J第一轮模拟考第四套 第 33 题

第三题

#include<iostream>
const int mod = 1000000007;
int exp();
int term()
{
    char dummy;
    std::cin >> dummy;
    int t = exp();
    std::cin >> dummy;
    if (t == 0) return 1;
    else return t*2 % mod;
}
int exp()
{
    int result = 0;
    while (std::cin.peek() == '(')
    {
        result += term();
        result %= mod;
    }
    return result;
}
int main()
{
    std::cout << exp();
}

exp() 函数返回 00 的情况是( )。

{{ select(1) }}

  • 输入为空
  • 遇到右括号
  • 遇到非法字符
  • 所有情况都不返回 00