|Submit||All submissions||Best solutions||Back to list|
HS12EQ - Equalities
Given a sequence of digits, insert the character = (equality sign) and two operators: + (plus) and - (minus) so as to form an equality of two arithmetic expressions.
- Do not rearrange the given sequence of digits.
- Place in between every two consecutive digits in the sequence exactly one of the symbols: plus, minus, or equality sign.
- Use the equality sign exactly once.
If there is more than one solution, find all of them.
First, you are given T, the number of test cases (T ≤ 10000). The test cases follow, one test per line. Each of the test cases consists of a sequence of digits. There are at least 2 and no more than 10 digits in the sequence. Digits are separated by spaces.
For each of the test cases print all requested equalities, one per line, in arbitrary order.
Input: 3 2 3 1 0 1 0 3 2 1 Output: 1=0+1-0 1=0+1+0 1-0=1-0 1-0=1+0 1+0=1-0 1+0=1+0 1-0-1=0 1+0-1=0 3=2+1 3-2=1
There are five sets of tests, each set worth 2 points
Set 1 - two digits in every test case.
Set 2 - three digits in every test case.
Set 3 - up to five digits in every test case.
Set 4 - up to ten digits in every test case, output size does not exceed 300KB
Set 5 - up to ten digits in every test case, output size does not exceed 2.5MB
|Added by:||Robert Janczewski|
|Cluster:||Cube (Intel G860)|
|Languages:||All except: ASM32-GCC ASM64 GAWK MAWK BC C-CLANG CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JS-MONKEY KTLN NIM NODEJS OBJC OBJC-CLANG OCT PICO PROLOG PYPY PY_NBC R RACKET RUST CHICKEN SED SQLITE SWIFT UNLAMBDA VB.NET|
|Resource:||High School Programming League|