Childs PlayProblem code: DPC210 |
All submissions for this problem are available.
Child s Play
Anu is a little girl who has an extraordinary skill in playing with numbers. You give her a set of nonzero
positive integers with or without repetitions and tell her to generate all possible distinct nonzero positive integers
by retaining / adding / subtracting any combination of the given integers. She can do so instantly.
For example if you give her the three integers 2, 8, 3 then in a moment she will tell you that a total of 11
integers can be generated. In fact, the 11 integers are the following: 1, 2, 3, 5, 6, 7, 8, 9, 10, 11 and 13.
You are required to write a program that equals the skill of Anu.
Input
The input may contain multiple test cases.
The first line of each test case gives two integers: the case number c and the total number k (< 15) of
integers given to Anu. The next line gives k integers in any order. A blank character separates two consecutive
integers in input.
The input terminates with an input 0 for c.
Output
For each test case print output in one line, giving the case number c and the total number of integers that
can be generated.
Sample Input
1 2
2 3
2 3
2 3 8
3 4
2 5 5 4
0
Sample Output
1 4
2 11
3 14
| Author: | rushikesh30 |
| Date Added: | 11-03-2010 |
| Time Limit: | 1 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.

Fetching successful submissions

Hi Admin: I posted my
Hi Admin: I posted my solution by mistake in the comments. Please remove it if you want to.