BLOPER - Operators
Giới hạn- Thời gian: 0.1s
- Bộ nhớ: 1536MB
- Mã nguồn: 50000 bytes
Given a set of N integer A = {1, 2, 3, …, N} and a integer S, your task is find a way to insert an operator ‘+’ or ‘-‘ to every neighbor pair of A, that the result of the expression after insert equal to S.
Input
A single line, N and S (1 ≤ N ≤ 500, |S| ≤ 125250)
Output
If there are way(s) to insert, outputs any of them, otherwise outputs “Impossible” (without quotes).
Example
Input: 9 5 Output: 1-2+3-4+5-6+7-8+9 Input: 5 6 Output: Impossible
You may want to try another version here
- Người up: kata69