Under construction

Still being built. Things may change

Four Operations

Time limit2sMemory limit512 MB

Summary
Starting from s, apply +, -, *, / (each replacing s with s+s, s-s, s*s, or s/s) to reach t in the fewest steps, ties broken lexicographically.
Level

Medium5 of 10

Topics
BFS, Math, Brute force
Solved
No attempts yet

Problem

You are given an integer ss. Write a program that finds the minimum number of operations needed to turn the value of ss into tt.

The available operations are:

  1. s = s + s; (output: +)
  2. s = s - s; (output: -)
  3. s = s * s; (output: *)
  4. s = s / s; (output: /) (allowed only when ss is not 0)

Input

The first line contains two integers ss and tt separated by a space. (1≤s,t≤1091 \le s, t \le 10^9)

Output

On the first line, print a way to turn ss into tt as the string formed by concatenating the output characters of the operations in the order they are applied. Only a way with the minimum number of operations counts as an answer. If ss and tt are equal, print 0. If ss cannot be turned into tt, print -1.

If several ways use the minimum number of operations, print the lexicographically smallest one. In ASCII order the operation characters are *, +, -, /.

Examples6

  1. Example 1

    Input
    7 392
    
    Expected output
    +*+
    
  2. Example 2

    Input
    7 256
    
    Expected output
    /+***
    
  3. Example 3

    Input
    4 256
    
    Expected output
    **
    
  4. Example 4

    Input
    7 7
    
    Expected output
    0
    
  5. Example 5

    Input
    7 9
    
    Expected output
    -1
    
  6. Example 6

    Input
    10 1
    
    Expected output
    /