#P11605. Construct a Valid Expression with Ones
Construct a Valid Expression with Ones
Construct a Valid Expression with Ones
Given a positive integer \(k\), construct a valid expression that uses only the characters 1
, +
, *
, (
, and )
such that:
- There are no two adjacent \(1\)'s.
- The total number of \(1\)'s is at most 100.
- The value of the expression is \(k\).
You are also given the formal definition of a valid expression:
1
is a valid expression.- If
a
andb
are valid expressions, thena+b
,a*b
,(a+b)
and(a*b)
are valid expressions.
If a valid expression satisfying the constraints exists, output it; otherwise, output no solution
.
inputFormat
The input consists of a single line containing a positive integer \(k\).
Constraints:
- \(1 \le k \le 10^9\) (practically, only values for which a solution exists under the \(1\)'s limitation will be tested).
outputFormat
Output one line: the constructed valid expression that evaluates to \(k\) if one exists. If no valid expression exists, output no solution
.
sample
1
1