Sum that line

Write a program that reads a series of lines, each of them containing a
sequence of non negative integers, and prints as output the value of the
sum of the first line that contains an even number of elements ending in
3. If there is no such line, the output will be -1.

For instance, for the input:

    23 12 4 25
    44 43 23 3 12 8
    33 4 9 73 14
    88 92 55

The output would be 133, because the third line contains 2 numbers
ending in 3 (33 and 73), and the previous lines contained an odd number
of such elements (1 and 3 respectively).
Thus, the third line is the first with an even number of elements ending
in 3. The sum of the element of this line is 33+4+9+73+14 = 133

Input

The input is a series of lines with numbers. Each line contains at least
one number.

Output

The output is the sum of the elements in the first line that happens to
have an even number of elements ending in 3, or -1 if there is no such
line.

Problem information

Author: ProAl professors

Generation: 2026-01-25T17:20:28.986Z

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