BF Calculator

题意翻译

## 题目描述 在这个问题中,你要写一个可以生成[Brainfuck](https://en.wikipedia.org/wiki/Brainfuck)语言的代码以算出数学表达式值的生成器。 给你一个算术表达式,其中包括数字0~255以及加减号,你需要生成一个可以算出并输出算术表达式结果的Brainfuck代码 我们将用一个绝对标准的Brainfuck编译器来判断你的Brainfuck代码的正误。 - 有30000个位置供你使用。 - 一个位置用无字符8比特的位置储存0~255的整数。 - 不支持输入(即不能出现','请求输入),在本题中也并不需要。 ## 输入输出格式 ## 输入格式: 输入仅有一行,包括一个算术表达式,内含2~10次运算对象,数字用 + 和/或 - 分离。每个运算对象将是一个在0和255间的整数。保证输出为0与225间的整数(在计算过程中可能会超出储存范围)。 ## 输出格式: 输出一个Brainfuck程序,以计算表达式的值,这个表达式不得多过5000000个字符,在50000000次操作内就要结束。 ## 输入输出样例 输入样例#1: ``` 2+3 ``` 输出样例#1: ``` ++>; +++>; <;[<;+>;-]<; ++++++++++++++++++++++++++++++++++++++++++++++++. ``` 输入样例#2: ``` 9-7 ``` 输出样例#2: ``` +++++++++>; +++++++>; <;[<;->;-]<; ++++++++++++++++++++++++++++++++++++++++++++++++. ``` ## 说明 你可以在网站[http://assets.codeforces.com/rounds/784/bf.cpp](http://assets.codeforces.com/rounds/784/bf.cpp)下载Brainfuck编译器。我们将用此测试你的Brainfuck代码。 ``` (温馨提示(若有需要,酌量增加) 设指针为now=0,内存为arr[]={0} 在第一个样例中 分号#1:将arr[0]设为2后将now设为1 分号#2:将arr[1]设为3后将now设为2 分号#3:将now设为1 在arr[now]!=0时循环,运行分号#4、#5前后的内容 分号#4:将now减1 分号#5:将arr[now]加1后将now加一 分号#5后一个字符:将now[arr]减一 循环三次后退出循环,此时储存仅有arr[0]为非0整数5,now为1 分号#6:将now设为0 分号#6后:将arr[now]加上48后输出arr[now]所代表的字符,即'5' 代码遍历完成,程序结束 ``` Translated by @tiger2005

题目描述

In this problem you will write a simple generator of Brainfuck (<https://en.wikipedia.org/wiki/Brainfuck>) calculators. You are given an arithmetic expression consisting of integers from 0 to 255 and addition/subtraction signs between them. Output a Brainfuck program which, when executed, will print the result of evaluating this expression. We use a fairly standard Brainfuck interpreter for checking the programs: - 30000 memory cells. - memory cells store integers from 0 to 255 with unsigned 8-bit wraparound. - console input (, command) is not supported, but it's not needed for this problem.

输入输出格式

输入格式


The only line of input data contains the arithmetic expression. The expression will contain between 2 and 10 operands, separated with arithmetic signs plus and/or minus. Each operand will be an integer between 0 and 255, inclusive. The calculations result is guaranteed to be an integer between 0 and 255, inclusive (results of intermediary calculations might be outside of these boundaries).

输出格式


Output a Brainfuck program which, when executed, will print the result of evaluating this expression. The program must be at most 5000000 characters long (including the non-command characters), and its execution must be complete in at most 50000000 steps.

输入输出样例

输入样例 #1

2+3

输出样例 #1

++&gt;
+++&gt;
&lt;[&lt;+&gt;-]&lt;
++++++++++++++++++++++++++++++++++++++++++++++++.

输入样例 #2

9-7

输出样例 #2

+++++++++&gt;
+++++++&gt;
&lt;[&lt;-&gt;-]&lt;
++++++++++++++++++++++++++++++++++++++++++++++++.

说明

You can download the source code of the Brainfuck interpreter by the link <http://assets.codeforces.com/rounds/784/bf.cpp>. We use this code to interpret outputs.