0

Arithmetic Expressions

5-year-old Shinchan had just started learning Mathematics. Meanwhile, one of his studious classmates, Kazama, had already written a basic calculator which supports only three operations on integers: multiplication(X), addition (+), and subtraction . (-). Since he had just learned about these operations, he didn't know about operator precedence, and so, in his calculator, all operators had the same precedence and were left-associative. As always, Shinchan started to irritate him with his silly questions. He gave Kazama a list of 'n' integers and asked him to insert one of the above operators between each pair of consecutive integers such that the result obtained after feeding the resulting expression in Kazama's calculator is divisible by '101' . At his core, Shinchan is actually a good guy, so he only gave lists of integers for which an answer exists. Can you help Kazama create the required expression? If multiple solutions exist, print any one of them. *Input Format* The first line contains a single integer 'n' denoting the number of elements in the list. The second line contains 'n' space-separated integers a1,a2,a3,....,an denoting the elements of the list. *Constraints* * 1 <= ai <= 100 *The length of the output expression should not exceed 10n . *Output Format* Print a single line containing the required expressoin. You may insert spaces between operators and operands. *Note* *You are not allowed to permute the list. *All operators have the same precedence and are left-associative, e.g., a + b x c -d x e is interpreted as ((((a + b ) x c ) - d ) x e ) *Unary plus and minus are not supported, e.g., statements like -a , a x -b, -a x b +c or are invalid. for Examples of Output & Input, Use this Link "https://www.hackerrank.com/challenges/arithmetic-expressions/problem"

12th Apr 2018, 1:46 PM
Pauly😊💖
Pauly😊💖 - avatar
1 Odpowiedź
0
Q&A is not a place for challenges
16th Aug 2018, 12:10 AM
I Am Arthur
I Am Arthur - avatar