Sum of the elements behind P62059


Statement
 

pdf   zip

html

Write a program that reads a sequence of integer numbers and prints how many of them are equal to the sum of all the elements which are behind them.

Input

Input is a sequence of integer numbers.

Output

In a line, print the number of integer numbers of the input sequence that are equal to the sum of all the elements which are behind them.

Observation

Use recursion (not tables).

Public test cases
  • Input

    -34 11 7 2 -8 5 3 2
    

    Output

    3
    
  • Input

    4 2 2 0
    

    Output

    3
    
  • Input

    
            
                                

    Output

    0
    
  • Input

    0 32 -16 -8 -4 -2 -2 
    

    Output

    5
    
  • Input

    28 32 -5 9
    

    Output

    0
    
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++ Python