logo AlgoBeat OnlineJudge
登录 注册

#215790. [JAG 2024 Summer Camp #2] Expression Sum

内存限制:1024 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are given a string . Each character in is one of ?

Let be a string formed by replacing each in with one of . Define as follows:

  • If is a valid expression, then it is the value obtained by evaluating as an expression.
  • If is not a valid expression, then it is .

Compute the sum of for all possible ways to replace each in with one of , and output the result modulo .

A valid expression is defined by the following BNF:

输入格式

The input is given in the following format:

  • Each character of is one of ?

输出格式

Output the answer.

样例

样例输入 1

?1?

样例输出 1

46306

样例输入 2

20???0+2??

样例输出 2

651059511