SUMFOUR - 4 values whose sum is 0

题意翻译

给定4个数列A,B,C,D。要从每个数列中取出1个数,使4个数的和为0。求出这样的组合个数。当一个数列中有多个相同的数字时,把他们作为不同的数字看待。 输入: 第一行:n 以下n行,每行4个数,第i行为ai,bi,ci,di。 输出: 组合数个数。 限制: n<=4000; |ai,bi,ci,di|<=2^28

题目描述

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 ) belongs to 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

输入输出格式

输入格式


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 . (**Edited:** n <= 2500)

输出格式


Output should be printed on a single line.

输入输出样例

输入样例 #1

6
-45 22 42 -16
-41 -27 56 30
-36 53 -37 77
-36 30 -75 -46
26 -38 -10 62
-32 -54 -6 45

输出样例 #1

5