We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home
  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Functional Programming
  3. Memoization and DP
  4. Expressions

Expressions

Problem
Submissions
Leaderboard
Discussions

5 year old Shinchan had just started learning Mathematics. Meanwhile, one of his studious classmate, Kazama, had already written a basic calculator which supports only 3 operations on integral numbers: multiplication , addition , and subtraction . Since he had just learnt about these operations, he didn't have knowledge of precedence of operators, and in his calculator all operators had same precedence and left associativity.

As always Shinchan started to irritate him with his silly question. He gave Kazama a list of integers and asked him to insert one of the above operators between each pair of consecutive integer such that the result obtained after feeding the resulting expression in Kazama's calculator is divisible by . At core Shinchan is a good guy, so he gave only that list of integers for which the answer always exists.

Can you help Kazama in creating the required expression? If multiple solutions exists, print any one of them.

Input Format

First line contains an integer, , representing the number of elements in the list. In next line there are space separated integers representing the list.

Constraints

  • Length of output expression should not exceed .

Note

  • You are not allowed to permute the list.
  • All operators have same precedence order and left associativity, ie.,
  • Unary plus and minus are not supported, ie., statement like , , are invalid.

Output Format

Print the resultant expression. You can insert 0 or more spaces between operators and operands.

Sample Input 0

3
22 79 21

Sample Output 0

22*79-21

Explanation 0

Solution 1: , where and it is perfectly divisible by 101.
Solution 2: , which is another multiple of 101.

Sample Input 1

5
55 3 45 33 25

Sample Output 1

55+3-45*33-25

Explanation 1

which is also divisible by 101.

Author

deepakgupta

Difficulty

Hard

Cutoff Score

39.96

Max Score

40

Submitted By

511

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Helpdesk
  • Careers
  • Terms Of Service
  • Privacy Policy

Cookie support is required to access HackerRank

Seems like cookies are disabled on this browser, please enable them to open this website