P0012. Diabolical numbers P79123


Statement
 

pdf   zip

html

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 −1 , 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:

||
n14617202328140255999999972
n in basis 41101210111011313020303333323212230213210
sum of the digits113225451227
diabolicalNoYesYesNoYesNoNoYesNoYes
||

Input

The input consists of a sequence of integers strictly positive finished in −1-

Output

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.)

Public test cases
  • Input

    -1
    

    Output

    000000
    
  • Input

    20 -1
    

    Output

    000001
    
  • Input

    17 4 6 20 20 23 140 28 255 999999972 1 2 -1
    

    Output

    000006
    
  • Input

    4 4 4 4 4 4 4 4 4 4 4 4 -1
    

    Output

    000012
    
  • Information
    Author
    Professorat de P1
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++