Count
Time Limit: 1000 ms
Memory Limit: 65536 KiB
Problem Description
You are given an integer array s[] and are asked to count how many positions a, b, c and d satisfy the condition: s[a] + s[b] + s[c] == s[d].
Note that a, b, c, and d do not need to be distinct.
Input
The first line of input contains an integer T, indicates the cases.
Each of the next T blocks contains an integer n first (0< n ≤1000 ), the length of the array s[], following with n integers representing s[] (0≤ si≤10^6 ).
Output
Output T lines each contains the answer required. You'd better use 'long long' instead of 'int'.
Sample Input
4 4 0 0 0 0 2 1 3 4 1 10 100 111 1 3
Sample Output
Case #1: 256 Case #2: 1 Case #3: 6 Case #4: 0
Hint
Source
HDU shadow95