当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2269:Friends

题目描述
You want to plan a big birthday party with your friends. On planning you notice that you have to do a lot of operations with sets of friends. There is one group which consist of Arthur, Biene and Clemens. Then there is a group of friends you know from snowboarding which consists of Daniel, Ernst, Frida and Gustav. If you want to invite them both, the resulting party group consists of g1 + g2 (the result is the union of both groups). Then you can compute the intersection of the two groups g1 * g2, which consists of the empty set. Maybe you want to invite a group g1, but excluding all members of an other group g2, which is written as g1 - g2.
Intersection (*) has precedence over union (+) and set difference (-). All operations are left associative, which means that in A op1 B op2 C you first have to evaluate A op1 B (provided op1 and op2 have equal precedence).
输入解释
The input consists of one or more lines. Each line contains one expression that you have to evaluate. Expressions are syntactically correct and only consist of the characters:
  • '{' and '}'
  • the elements 'A' to 'Z' meaning friend Arthur to Zora.
  • the operations '+', '-' and '*'
  • '(' and ')' for grouping operations
  • the newline character '\n' marking the end of an expression.

A line is never longer than 255 characters.
输出解释
Output the resulting set in curly braces '{' and '}', each on a line of its own. Print elements of sets sorted alphabetically.
输入样例
{ABC}
{ABC}+{DEFG}+{Z}+{}
{ABE}*{ABCD}
{ABCD}-{CZ}
{ABC}+{CDE}*{CEZ}
({ABC}+{CDE})*{CEZ}
输出样例
{ABC}
{ABCDEFGZ}
{AB}
{ABD}
{ABCE}
{CE}

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Ulm Local 1999

源链接: POJ-2269

最后修改于 2020-10-29T06:28:05+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536