Submit | All submissions | Best solutions | Back to list |
BLOPER - Operators |
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
Added by: | Kata |
Date: | 2014-03-28 |
Time limit: | 0.100s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
hide comments
|
||||||
2023-08-17 08:27:49
getting TLE using Java , at TC 25 , pls help ! |
||||||
2022-11-24 09:24:39
<snip> I'm right ? [Simes]: use the forum for questions about code Last edit: 2022-11-24 09:30:05 |
||||||
2021-03-03 15:31:44
can i use any number of + and - in this question |
||||||
2021-01-10 12:43:22
What is greedy parameter in it? |
||||||
2021-01-04 10:13:28
I am using recursion to solve this problem but getting TLE in test case 25. someone please help code: <snip> [NG]: Read the footer. Last edit: 2021-01-04 15:55:14 |
||||||
2020-11-04 21:53:22
@raviteja_3272 your solution fails but you cant tell where. it could be on the first, last or every test case. |
||||||
2020-10-25 19:59:38
test case 25 ??!!! my solution fails on it |
||||||
2020-10-21 14:21:37
is putting a - before 1 valid ??? |
||||||
2020-09-03 16:24:39
what is test 25 ??!!! my solution fails on it |
||||||
2020-07-17 22:52:37 Shubham Jadhav
lots of silly mistakes |