Similar sequences (2)

In this problem, we say that two sequences of numbers are similar if
both have the same sum and finalize with the same number. Provide a
program that computes how many of the given sequences are similar to the
first (this one included).

In your program, you have to implement and use the following procedure:

  void info_sequence(int& sum, int& last);

which reads a sequence from the input and computes the parameters sum
and last, the sum of the elements and the last element of the read
sequence, respectively.

Input

The input is formed by one or more non-empty sequences of natural
numbers all of them strictly positive. Each sequence is finalized by a
0. The end of the input is marked with an empty sequence.

Output

Print how many sequences are similar to the first one, including the
first.

Observation

You cannot use strings, vectors or other data structures.

Problem information

Author: Unknown
Translator: Professorat PRO1

Generation: 2026-01-25T22:45:21.408Z

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