编程介的小学生 2017-10-03 16:18 采纳率: 20.5%
浏览 766
已采纳

D++ Again

Description

The language D++, that was perfected by the participants of our March competition, continues improving. Its founders try to make the syntax as clear as it is possible in order to make the programming simpler in the future.
Of course, some minimal set of rules is to stay without changes. Your program is to check the observance of rules, concerning the arrangement of brackets and comments.

A text of a correct D++ program contains a symbol part, arithmetic expressions and comments. Comments may appear everywhere and may contain every symbol. A comment is always opened by a pair of symbols "(*" and is closed by a pair of symbols "*)". Each comment must be closed. An arithmetic expression in D++ is always opened by "(", is closed by ")" and may contain any of the following symbols: "=+-*/0123456789)(" and, surely, comments. No spaces in arithmetic expressions are allowed, though a carriage return may occur. You may run across embedded brackets in an arithmetic expression. In this case these brackets are to be balanced. It means that "((1)))" as well as "(23))((+)" are not correct arithmetic expressions. An arithmetic expression is correct if and only if brackets placed correctly. At last, all the rest of the program text (the result of rejection of all comments and arithmetic expressions from the initial text of the program) may contain every symbol excluding "(" and ")".
We would like to especially notice that the spaces are posiible anywhere in a text of a program except when apppeearing in arithmetic expressions.
Input

Some text is written in the standard input. There are not more than 10 000 symbols in the text. There may be Latin letters, digits, brackets, symbols of arithmetic operations and the symbols "end of line" and "carriage return".
Output

Your program should write "YES" to the output if the introduced text is a correct D++ program, and "NO" otherwise.
Sample Input

Hello, here is a sample D++ program. It contains some arithmetical expressions like
(2+2=4), (2+-/*) and ((3+3)*3=20(*this is not true, but you don't have to verify it :-) )+8)
(
the closing bracket in the previous comment is also in order, since this bracket
does not belong to any arithmetical expression*)
Sample Output

YES

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-10-19 11:04
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器