Valid Expression CodeChef Solution

We Are Discuss About CODECHEF SOLUTION

Valid Expression CodeChef Solution

Valid Expression CodeChef Solution

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW
JoinScishowEngineerTelegram

Problem

The correct way of evaluating an expression with ∗,+, and  is, first multiplication, then addition, and then subtraction. For example, the expression 2+3∗7−5=2+21−5=23−5=18.

You are given integers  and . Your task is to generate a string  of length  consisting only of ∗,+, and  such that when these  operators are placed in order between (�+1) ones, the result of the expression becomes .
For example, if �= ++-*-, the resulting expression is 1+1+1−1∗1−1, which is then evaluated based on the rules above.

If multiple such strings exist, print any of them. If no such string exists, print −1 instead.

Input Format

  • The first line of input will contain a single integer , denoting the number of test cases.
  • Each test case consists of two space-separated integers  and  — the number of characters in the string and the result of expression after appending (�+1) ones between all operators.

Output Format

For each test case, output on a new line a string  of length  consisting only of ∗,+, and  that satisfies the given condition.

If multiple such strings exist, print any of them. If no such string exists, print −1 instead.

Constraints

  • 1≤�≤2000
  • 1≤�≤105
  • −105≤�≤105
  • The sum of  over all test cases won’t exceed 2⋅105.

Sample 1:

Input

Output

3
3 4
2 -5
3 1
+++
-1
*+-

Explanation:

Test case 1: A possible string satisfying the condition is +++. The corresponding expression is 1+1+1+1=4 which is equal to .

Test case 2: It can be proven that no such string with length �=2 exists such that the corresponding expression evaluates to −5.

Test case 3: A possible string satisfying the condition is *+-. The corresponding expression is 1∗1+1−1=1+1−1=2−1=1 which is equal to .
Note that there are other valid strings, such as +*- and -*+. Any valid string will be accepted as output.

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW
JoinScishowEngineerTelegram

 

SOLUTION

Here Discuss About Solve Valid Expression CodeChef Solution

SOLUTION

Valid Expression CodeChef Solution

SOLUTION

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *