Programming contests

DEIK Regionális Programozó Csapatverseny, egyetemi/főiskolai kategória, 2013. december 1.

December 1, 2013 10:30 AM – December 1, 2013 3:30 PM

Triples

Given a sequence of positive integers, you need to find the number of triples in that sequence. For this problem, (xyz) constructs a triple if and only if x + y = z. So, (1, 2, 3) is a triple, while (3, 4, 5) is not.

Input Specification

The input consists of several test cases. Each test case starts with a positive integer N (3 ≤ N ≤ 5000). The next few lines contain N positive integers. The input is terminated by EOF.

Output Specification

For each test case, print the number of triples in the sequence in a line by itself.

Sample Input

  1. 6
  2. 1 2 3 4 5 6
  3. 6
  4. 1 2 4 8 16 32
  5. 3
  6. 100000000 200000000 100000000
  7. 5
  8. 1 1 1 2 2
download as text file

Output for Sample Input

  1. 6
  2. 0
  3. 1
  4. 6
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019