Logo
(追記) (追記ここまで)

19093번 - Ones 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB54332976.316%

문제

Let us define 1-expressions to be the numeric expressions containing only ones, addition signs, multiplication signs and parentheses. In such expressions no two digits can be neighboring -- every two ones must be separated by an operator. We follow the usual order of evaluating the expressions -- for example, the multiplication has larger priority than the addition.

For example, each of the following 1-expressions evaluates to 6:

(1+1)*(1+1+1), (1+1+1)*(1+1)*1, ((1+1)+1)*(1+1), 1+1+1+1+1+1, 1+(1+(1+(1+(1+1)))).

Formally, the following grammar describes all the correct 1-expressions $E$:

E ::= 1 | E+E | E*E | (E+E) | (E*E)

Write a program that, given an integer $k$ ($k \le 10^9$), outputs a 1-expression evaluating to $k$ that contains at most 100 ones.

입력

The first line of the input contains a single integer $t$ (1ドル \le t \le 100$) -- the number of testcases.

Each of the following $t$ lines describe a single testcase. The $i$-th of these lines describes the $i$-th test and contains a single integer $k_i$ (1ドル \le k_i \le 10^9$).

출력

You should output exactly $t$ lines.

If there is no 1-expression evaluating to $k_i$ and containing at most 100 ones, you should output NO in the $i$-th line. Otherwise, the line should contain the required solution. You should not print any spaces inside the expression. If there is more than one correct solution, print any.

제한

예제 입력 1

2
6
10

예제 출력 1

(1+1)*(1+1+1)
1+1+1+1+1+1+1+1+1+1

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2017 > Day 6: Warsaw U Contest, XVII OpenCup Onsite D번

Contest > Algorithmic Engagements > PA 2016 2-1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /