# 4 values whose sum is 0

Source: Internet
Author: User
Time limit:15000 Ms Memory limit:228000kb 64bit Io format:% I64d & % i64usubmit status

Description

The sum problem can be formulated as follows: given four Lists A, B, C, D of integer values, compute how many quadruplet (A, B, C, D) ε a x B x C x D are such that A + B + C + D = 0. in the following, we assume that all lists have the same size N.

Input

The first line of the input file contains the size of the lists N (this value can be as large as 4000 ). we then have n lines containing four integer values (with absolute value as large as 2 28) that belong respectively to A, B, C and D.

Output

For each input file, your program has to write the number quadruplets whose sum is zero.

Sample Input

`6-45 22 42 -16-41 -27 56 30-36 53 -37 77`
``` 1 #include<cstdio> 2 #include<string.h> 3 #include<algorithm> 4 #define MAXN 4400 5 using namespace std; 6 int A[MAXN],B[MAXN],C[MAXN],D[MAXN]; 7 int S[MAXN*MAXN]; 8 int lower_bound1(int low,int high,int num,int a[]) 9  {10      int mid;11      while(low

-36 30 -75 -4626 -38 -10 62-32 -54 -6 45
Sample output
5
HintSample explanation: indeed, the sum of the five following quadruplets is zero: (-45,-27, 42, 30), (26, 30,-10,-46 ), (-32, 22, 56,-46), (-32, 30,-75, 77), (-32,-54, 56, 30 ).```
Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.