您的位置:首页 > 其它

【SPOJ】Triple Sums【FFT】

2015-06-26 17:01 603 查看
题目:

You're given a sequence s of N distinct integers.

Consider all the possible sums of three integers from the sequence at three different indicies.

For each obtainable sum output the number of different triples of indicies that generate it.



Constraints:


N <= 40000, |si| <= 20000

Input

The first line of input contains a single integer N.

Each of the next N lines contain an element of s.

Output

Print the solution for each possible sum in the following format:

sum_value : number_of_triples

Smaller sum values should be printed first.

Example

Input:

5
-1
2
3
0
5
Output:

1 : 1
2 : 1
4 : 2
5 : 1
6 : 1
7 : 2
8 : 1
10 : 1




说明:Σx^2要怎么处理,这里表示的意思是指数是ai的2倍,那么它的系数即x^2的个数,就是ai的个数,Σx^3也是一样的,就是ai的三倍。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: