This page is still under construction.

Parts of this page are still being built. What you see may change.

Flexible Segments

Time limit1sMemory limit512 MB

Summary
For each n up to 10000, decide whether some n consecutive positive integers admit a +1/-1 choice per element preserving the product, and output the start and signs.
Level

Hard8 of 10

Topics
Number theory, Math, Greedy, Implementation
Solved
No attempts yet

Problem

The great mathematician Vladimir Germanovich noticed an interesting property of some segments of positive integers while searching for new patterns.

Vladimir calls the segment of positive integers l,l+1,…,rl, l + 1, \ldots, r flexible if he can change every number of this segment by exactly one in such a way that the product of the numbers in the segment does not change. That is, there exists a sequence al,al+1,…,ara_l, a_{l+1}, \ldots, a_r with the following properties:

  • ak=k±1a_k = k \pm 1
  • l⋅(l+1)⋅…⋅r=al⋅al+1⋅…⋅arl \cdot (l+1)\cdot \ldots \cdot r = a_l \cdot a_{l+1} \cdot \ldots \cdot a_r

Now Vladimir Germanovich wants to know whether he can build a flexible segment of any length. Given a positive integer nn, find any flexible segment consisting of nn consecutive positive integers, or report that no such segment exists.

Input

The only line contains an integer nn (1≤n≤10 0001 \le n \le 10\,000), the length of the required segment.

Output

The first line of output must contain "YES" if a flexible segment of nn positive integers exists. Otherwise it must contain "NO".

If such a segment exists, the second and third lines must contain the description of this segment.

The second line should contain the only integer ll (1≤l≤1 000 0001 \le l \le 1\,000\,000), the first element of this segment. It is guaranteed that if a flexible segment of length nn exists, then there exists a flexible segment [l;r][l; r] of length nn such that 1≤l≤1 000 0001 \le l \le 1\,000\,000.

The third line should contain a string of length nn without spaces. It must consist of "+" and "-" characters. The (k−l+1)(k-l+1)-th character of this string should be "-" if ak=k−1a_k = k - 1, or "+" if ak=k+1a_k = k + 1.

Hint

In the second example, n=4n = 4, l=2l = 2, r=l+n−1=5r = l + n - 1 = 5. The answer is as follows: a2=2−1=1a_2 = 2 - 1 = 1, a3=3+1=4a_3 = 3 + 1 = 4, a4=4+1=5a_4 = 4 + 1 = 5, a5=5+1=6a_5 = 5 + 1 = 6. The product of the integers from ll to rr is 2⋅3⋅4⋅5=1202 \cdot 3 \cdot 4 \cdot 5 = 120. The product of the aka_k is a2⋅a3⋅a4⋅a5=1⋅4⋅5⋅6=120a_2 \cdot a_3 \cdot a_4 \cdot a_5 = 1 \cdot 4 \cdot 5 \cdot 6 = 120. Thus, the segment [2;5][2; 5] is flexible.

Examples2

  1. Example 1

    Input
    1
    
    Expected output
    NO
    
  2. Example 2

    Input
    4
    
    Expected output
    YES
    2
    -+++