Problem:
-
Total time limit:
-
1000ms
-
Memory Limit:
-
65536kB
-
-
Describe
-
-
given an integer sequence, determine how many of them are equal to the sum of the other two numbers in the sequence. For example, for Series 1 2 3 4, the answer to this question is 2, because 3 = 2 + 1, 4 = 1 + 3.
-
-
Input
-
-
The first line is an integer t, which indicates how many sets of data are in total. 1<= T <= 100
The next group of data is divided into two rows, the first row is the number of numbers in the series n (1 <= n <= 100), the second row is a series of n integers.
-
-
Output
-
-
for each set of data, the output is an integer (one row), which is the number of numbers equal to the sum of the other two numbers in a sequence.
-
-
Sample input:
-
-
241 2 3 453 5 7 9 10
-
-
Sample output:
-
-
21st
Solution:
#include<iostream>using namespaceStd;int Main(){intN;Cin>>N;intB[N];intA[N][ -]; for(intI=0;I<N;I++){Cin>>B[I]; for(intJ=0;J<B[I];J++ ){Cin>>A[I][J];}} for(intI=0;I<N;I++){intC=0; for(intH=0;H<B[I];H++){intB=0; for(intW=0;W<B[I];W++){ for(intU=0;U<B[I];U++){if(A[I][H]==A[I][W]+A[I][U]&&W!=U&&W!=H&&U!=H){C++;B=1; Break;}}if(B==1){ Break;}}}cout<<C<<Endl;}return 0;}
Openjudge solution (c + +)--Question 3858: Sum