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

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

第三题

#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();
}

代码无法处理超过 200000200000 字符的输入,因为存在递归深度限制。

{{ select(1) }}

  • 正确
  • 错误