Home > Back-end >  Numbers may be repeated, but I didn't find logic errors
Numbers may be repeated, but I didn't find logic errors

Time:10-19

Title description
Abacus is a kind of done through simulation calculation in the brain change fast operation of a kind of computing technology, abacus training, both to the development intelligence, and can bring a lot of convenience for daily life, thus gained popularity in many school,

A school with abacus teacher USES a fast study the test method of bead mental arithmetic addition ability, he randomly generated a positive integer collection, a collection of several different, and then asked the students to answer: how many number, equals the set of the sum of the other two (different) number?

The teacher out some quizzes recently, would you please help to find out the answer,

(this topic is 2014 noip popularization T1)

Input format
A total of two lines, the first line contains an integer nn, said the positive integer number given in the test,

The second line with nn a positive integer, between every two positive integers separated with a space, said the test in the given positive integer


#include
#include

Int main ()
{
Int n, count=0, j, b, I;
The scanf (" % d ", & amp; n);
Int a [n].
for(i=0; iThe scanf (" % d ", & amp; A [I]);
for(i=0; ifor(j=0; J{
If (j==I)
continue;

For (b=j + 1; b{
If (b==I)
continue;
If (a==[I] a [j] + [b] a)

count++;



}
}
Printf (" % d ", count);
return 0;





}
  • Related