P0004. Strobogrammatic numbers P21895


Statement
 

pdf   zip

thehtml

Johnny, Roy and Steffy are studying for the final exams. While they are taking a break, they have the following dialogue:

Roy:
Have you seen that sign on the wall? They have hanged it upside down!
Johnny:
You are right but, curiously, there is a number, 6180819, it is the same hanged right or upside down.
Roy:
It’s true!
Steffy:
The numbers which have this property are called strobogrammatic numbers.
Roy:
What???
Steffy:
A natural number is called strobogrammatic number if it has the same value seen normally and upside down, taking into account that digits 0, 1 and 8 are symmetrical regarding to the horizontal axis, and that 6 and 9 are equal when are seen upside down.
Johnny:
The first 21 strobogrammatic numbers are 0, 1, 8, 11, 69, 88, 96, 101, 111, 181, 609, 619, 689, 808, 818, 888, 906, 916, 986, 1001 and 1111.
Steffy:
However, the numbers 12, 44 or 991 are not strobogrammatic numbers: the first two numbers can not be interpreted when they are upside down and the third one, read when it is upside down, represents 166. Notice that, excepting 0, any number ending in 0 is not an strobogrammatic number.



Your task is to write a program that indicates if several given natural numbers are or are not strobogrammatic numbers, and counts how many of the strobogrammatic numbers are odd numbers.

Your program must include and use the function

that indicates if a natural number |n| is or is not an strobogrammatic number.

Input

The input is a sequence of natural numbers.

Output

For each natural number of the input, print if it is an strobogrammatic number or it is not. Afterwards, print an empty line and the number of odd strobogrammatic numbers read. Follow the format of the instance.

Public test cases
  • Input

    1
    2
    8
    11
    101
    111
    1110
    0
    38
    18
    1881
    44
    69
    96
    99
    123456789
    969689696
    

    Output

    1 is strobogrammatic
    2 is not strobogrammatic
    8 is strobogrammatic
    11 is strobogrammatic
    101 is strobogrammatic
    111 is strobogrammatic
    1110 is not strobogrammatic
    0 is strobogrammatic
    38 is not strobogrammatic
    18 is not strobogrammatic
    1881 is strobogrammatic
    44 is not strobogrammatic
    69 is strobogrammatic
    96 is strobogrammatic
    99 is not strobogrammatic
    123456789 is not strobogrammatic
    969689696 is strobogrammatic
    
    odd strobogrammatic: 6
    
  • Information
    Author
    Professorat de P1
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++ Python