P0006. Fantastic numbers P79534


Statement
 

pdf   zip

thehtml

A natural number is called fantastic if all the digits in the even positions are even and all the digits in the odd positions are odd (the positions start to count from 1 on the right). For instance, 58361 and 6909 are fantastic, while 1212421 is not it (because the third digit is a 4, which is not odd).

Your task is to write a program that reads a sequence of natural numbers, prints how many there are, and also prints how many triplets of consecutive fantastic elements there are.

Your program must include and use

that indicates if a natural number |x| is fantastic or it is not.

Input

The input is a sequence of natural numbers x1, …, xn amb n≥ 0.

Output

Your program must print two lines following the format of the instances: a line with the number n of natural numbers read, and the other one with the number of indices i with ≤ and ≤ n − 2 such that xi, xi+1 and xi+2 are fantastic.

Public test cases
  • Input

    8 58361 6909 7 10101 1212421 21 43 1 9009
    

    Output

    fantastic numbers: 10
    fantastic triplets: 3
    
  • Input

    13 24 45 3 321 0 901
    

    Output

    fantastic numbers: 7
    fantastic triplets: 1
    
  • Input

    456789
    

    Output

    fantastic numbers: 1
    fantastic triplets: 0
    
  • Information
    Author
    Professorat de P1
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++ Python