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

建议使用的浏览器:

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

3131:One…Two…Five!

题目描述


The set of integers has rarely been a domain of error in everyday conversation. The king, however, is "three blind" and cannot visualize any number containing the digit '3' in its base 10 representation. He does intuitively sense the number between 2 and 4 and compensates for his blindness in the following manner: whenever he wants to state any number containing the digit '3', he will speak a series of numbers until they can all be combined (in the order given) via addition, subtraction, multiplication and division to produce the desired value which contains the digit '3'. Mathematical operators work from left to right without any other regard for order of precedence (i.e. 6 + 7 * 11 = 143 --> a number with a '3').

For example, if the king says "1 2 5", then a knight will say '3' using the following logic:

1 2 5 = 1 * 2 – 5 = 2 – 5 = |2 – 5| = 3

Note that there are no negative numbers in optimistic Camelot. Every subtraction will produce a nonnegative result by what is called, in these enlightened times, the absolute value. All division is integer division, i.e. 7/5 = 1. Obviously, if the number zero appears as a divisor, then division will not be attempted.

The court, however, has a problem. Some of the computations produce more than 1 number containing the digit '3'! You have been appointed to write a program which computes and displays the most frequently appearing number containing the digit '3'. In the event of a tie, use the largest number.
输入解释
The input will consist of an unspecified number of lines. Each line will contain at least 1 and at most 9 integers. Every number will be nonnegative and less than 100. A line with a single '#' character will be the end of input.
输出解释
For every line of input, print a line showing the number most probably meant by the king as described above. If there is no such number, print "No result".
输入样例
1 2 5
1 1
6 5 1
#
输出样例
3
No result
30
来自杭电HDUOJ的附加信息
Recommend chenrui

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3131

最后修改于 2020-10-25T23:00:22+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
10000/5000MS(Java/Others) 32768/32768K(Java/Others)