1348:Computing

题目描述
Input any five positive integral numbers n1, n2, n3, n4, n5, such that 0<=ni<=100, 1<=i<=5. To the first four positive integral numbers (n1, n2, n3, n4) the arithmetic operation, such as addition (+), subtraction (-), multiplication (*), or division (/) and brackets ('(',')') may be freely applied, but in the arithmetic expression formed with these numbers and operations, every one of the four integral numbers should be used once and only once.
Write a program for finding an arithmetic expression that satisfies the above requirement and equals n5.
输入解释
The input file consists of a number of data sets.Each data set is a line of 5 numbers separated by blank.A line of a single -1 represents the end of input.
输出解释
For each data set output the original data set first.If the program finds out the expression for these four arbitrary input numbers, then it gives out the output "OK!";On the contrary, if the program could not get the result of n5 by any arithmetic operations to the four input numbers, it gives output "NO!".
输入样例
1 2 3 4 50
2 3 10 1 61
-1
输出样例
1 2 3 4 50 NO!
2 3 10 1 61 OK!

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

题目来源 Xi'an 2002

源链接: POJ-1348

最后修改于 2020-10-29 06:01:42 UTC 由爬虫自动更新

共提交 0

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

·

·

·

·

登陆或注册以提交代码