We say that a number is diabolical if it is divisible for the double of the sum of its digits in basis 4. Your task is to write a program that, given a sequence of integers strictly positive finished in , counts how many of them are diabolical.
Your program must include and use the function
bool is_diabolical(int n);
that indicates if an integer |n| strictly positive is diabolical or is not.
These are some instances:
| 1 | 4 | 6 | 17 | 20 | 23 | 28 | 140 | 255 | 999999972 | |
|---|---|---|---|---|---|---|---|---|---|---|
| in basis 4 | 1 | 10 | 12 | 101 | 110 | 113 | 130 | 2030 | 3333 | 323212230213210 |
| sum of the digits | 1 | 1 | 3 | 2 | 2 | 5 | 4 | 5 | 12 | 27 |
| diabolical | No | Yes | Yes | No | Yes | No | No | Yes | No | Yes |
The input consists of a sequence of integers strictly positive finished in -
Your program must print the quantity of diabolical numbers of the sequence, with six digits. (The inputs will always have less than a million diabolical numbers.)
Author: Unknown
Translator: Carlos Molina
Generation: 2026-01-25T12:01:56.873Z
© Jutge.org, 2006–2026.
https://jutge.org