Related odd and even positions

Given a non-zero natural n, compute the sum of the digits in odd
positions and the sum of the digits in even positions. If one of the two
sums is a multiple of the other, your program has to print the relating
factor.

Input

The input is a non-zero natural number 0 < n < 2³¹.

Output

The output consists of two lines. The first line shows the sum of digits
in odd positions and the sum of digits in even positions. The second
line indicates the relationship among the two quantities, including the
exact relation when one is a multiple of the other.

 
Follow the format given in the examples.

Observation

Remember that the last digit of a natural number n occupies an odd
position. For example, for n = 212121, the odd positions are those
occupied by 1’s and the even positions are those occupied by 2’s.

 

Problem information

Author: Unknown
Translator: Maria J. Serna

Generation: 2026-01-25T17:38:44.008Z

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