OpenJudge exercises (C ++) -- question 3858: and
Question:
-
Total time limit:
-
1000 ms
-
Memory limit:
-
65536kB
-
Description
-
Given an integer sequence, determine the number of numbers, which is equal to the sum of the other two numbers in the series. 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, indicating the total number of data groups. 1 <= T <= 100
The following data is divided into two rows. The first row is the number n (1 <= n <= 100) in the number series, and the second row is a series composed of n integers.
-
Output
-
For each group of data, an integer (one row) is output, that is, the number of numbers in a series that is equal to the sum of the other two numbers.
-
Sample input:
-
241 2 3 453 5 7 9 10
-
Sample output:
-
21
Solution:
#include<iostream>using namespace std;int main(){int n;cin>>n;int b[n];int a[n][100];for(int i=0;i<n;i++) cin="">>b[i];for(int j=0;j<b[i];j++ cin="">>a[i][j];}}for(int i=0;i<n;i++) int="" c="0;" h="0;h<b[i];h++)" b="=1)" w="0;w<b[i];w++)" u="0;u<b[i];u++)" return="" pre=""><p></p> </n;i++)></b[i];j++></n;i++)></iostream>