3rd BUBT Intra-University Programming Problem I

Problem I
Mathematics for Jane
Background Story
Steven and Grace want to teach basic Mathematics to their baby daughter, Jane.
Grace bought “flash cards” that contains one or more dots.
Here are some examples of those cards:
Card 1:     Card 2:     Card 3:
——-     ——-     ——-
|     |     |   * |     |*  * |
|  *  |     |     |     |    *|
|     |     | *   |     |*  * |
——-     ——-     ——-
Card 1 is actually number 1, Card 2 is number 2, Card 3 is number 5.

The creator of these flash cards claims that babies can spot the number of dots faster than adults.
Problem Description
The issue here is that my wife Grace only bought N such cards, and some of them are the same.
Steven wants to teach more numbers to Janeā€¦
Suddenly Steven realizes that he can actually combine two cards to produce a new number!!
For example, if Steven combines Card 1 and Card 3, he can teach Jane number: 1+5 = 6 :).
Being a computer scientist, Steven wonders, how many different numbers that he can teach to Jane by using single card and also by combining two cards?
Input
For each test case there are two line. First line contain one integer, N (1 <= N <= 20), that denotes the number of flash cards bought by Grace. Then next line contain Npositive integers less than 100 that denote the number of dots on each flash card. These N flash cards are not necessarily unique as described in the problem description above.
Output
For each test case, print an integer in one line to answer Steven’s question above.
Sample Input
Sample Output
4  
1 1 1 1
3  
1 2 5
2  
10 1
2  
1 1
1
7
2
6
3
2
1
______________________________________________________________________________
Problem Setter: Dr. Steven Halim, Lecturer
NATIONAL UNIVERSITY OF SINGAPUR (NUS)
At First you can try to solve this problem if you can’t than see this code & find what’s your problem . If you copy paste this code you could not improve yourself in programming .

Posted by Shipu Ahamed

Leave a Reply