Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Language: Computing
Description 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. Input 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. Output 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!". Sample Input 1 2 3 4 50 2 3 10 1 61 -1 Sample Output 1 2 3 4 50 NO! 2 3 10 1 61 OK! Source |
[Submit] [Go Back] [Status] [Discuss]
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator