F003B. Twin numbers P66047


Statement
 

pdf   zip

thehtml

Two natural numbers are twins if the number of appearances of each digit is the same in each of them. For instance, 25 and 52 are twins, as well as 1225 and 5212. Neither 7899 and 7889, nor 102 and 12 are twins.

Your task is to write a program that says which numbers do not have any twin in a given set.

Your program must include and use the function

That indicates if two different natural numbers |a| and |b| are twins.

Input

The input is a sequence of cases. Each case starts with a word that identifies it, followed by a natural number n, followed by n natural numbers strictly positive, all different.

Output

For each input case, print a line starting with the case id, followed by the list of the numbers which are not twins of any other number of the same case, and ending with the counter of written numbers. The numbers have to be in the order that they have been given at the input. Follow the format of the instance.

Public test cases
  • Input

    coffee      8   218 4 789 82 281 333 182 28
    thyme       3   123 321 213
    mint        5   789 12 45 98 798
    rosemary    0
    tea         1   789
    chocolate   9   10 1 11 101 100 110 123321123 333222111 1111222333
    

    Output

    Case coffee: 4 789 333 (total 3)
    Case thyme: (total 0)
    Case mint: 12 45 98 (total 3)
    Case rosemary: (total 0)
    Case tea: 789 (total 1)
    Case chocolate: 10 1 11 100 1111222333 (total 5)
    
  • Information
    Author
    Professorat de P1
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++ Python