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

23503번 - My Number 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 256 MB31133.333%

문제

Taaaamara is big fan of the Serbian quiz "Slagalica". Her favourite game in the quiz is "My Number". In this game you get a set of integers $S$ and one target number $T$. You can use use each element from $S$ at most once and some mathematical operations to build a valid mathematical expression equal to $T$. For example, if you have $S$ = {2,ドル 5, 2, 15, 10$} and $T = 38,ドル one valid expression can be: 2ドル \times (15 + 5)-2$.

Today, Taaaamara is playing one modification of this game:

  • She has an array $A$ with $n$ integers, all elements in $A$ are target numbers.
  • She needs to find an array $B$ with $k$ elements (elements in $B$ don't have to be different), all elements in $B$ should be integers in range $[1, 10^8]$.
  • She wants to build one valid mathematical expression for each of the target numbers $A_i$ using only elements from $B$. In case some element appears $x$ times in $B,ドル you can use that element at most $x$ times for each of the expressions.
  • She can use the following binary operators: '+' (addition), '-' (substraction),'*' (multiplication), Divison is not allowed. She can use brackets too.
  • The length of array $B$ $(k)$ is not fixed, but as everybody knows Taaaamara is smart girl, so she wants to find an array $B$ with length not bigger than 12ドル$ $(k \leq 12)$.

Can you help her?

입력

First line of input contains number $n$ $(1 \leq n \leq 124)$. Second line of input contains $n$ integers, array $A$ $(1\leq A_i \leq 10^8)$.

출력

In the first line of output print number $k \leq 12,ドル the length of array $B$. In the second line of output print $k$ integers, elements of array $B$. Each of next $n$ lines contains one valid mathematical expression, in the $i$-th line, the value of the expression should be equal to $A_i$. Expressions should be in the following format:

  • Each expression has at most 1000ドル$ characters.
  • For the addition of two numbers you can use character '+' (ascii value 43ドル$).
  • For the substraction of two numbers you can use character '-' (ascii value 45ドル$).
  • For the multiplication of two numbers you can use character '*' (ascii value 42ドル$).
  • for brackets use characters '(' (ascii value 40ドル$) and ')' (ascii value 41ドル$).
  • It is not allowed to use operators '+' and '-' as unary operators. For example expressions $-5 + 3$ and 5ドル - -3$ are not valid.
  • Besides the characters listed above you can only use numbers from $B$ and space charactes ' ' (ascii value 32ドル$). Special formatting of the output is not needed (see example).

제한

예제 입력 1

6
30 13 15 5 3 21

예제 출력 1

3
2 5 3
2*5*3
5*3- 2
5 *3
 (5)
5 -2
3* (5+2 )

힌트

출처

Contest > Open Cup > 2019/2020 Season > Stage 19: The Grand Prix of Serbia E번

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

출처

대학교 대회

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

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