P0006. Fantastic numbers

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

        bool is_fantastic(int x);

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

Input

The input is a sequence of natural numbers x₁, …, x_(n) 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 x_(i), x_(i + 1)
and x_(i + 2) are fantastic.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T12:03:21.886Z

© Jutge.org, 2006–2026.
https://jutge.org
