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

Fetching successful submissions

Please register at
Please register at http://bit.ly/DSPPC2_Register to claim prizes and certificates.