【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
Each of the next N lines contain an element of s.
sum_value : number_of_triples
Smaller sum values should be printed first.
说明:Σx^2要怎么处理,这里表示的意思是指数是ai的2倍,那么它的系数即x^2的个数,就是ai的个数,Σx^3也是一样的,就是ai的三倍。
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的三倍。
相关文章推荐
- CentOS6.5 64位网站压力测试工具webbench
- 你的企业是否需要开发APP?
- [XCode] InterfaceBuilder 误操作导致的uncaught exception 'nsunknownkeyexception'异常
- Java学习-017-EXCEL 文件读取实例源代码
- MFC把一个工程中的对话框复制到另一个工程中
- 接口中图片的接收
- C#中文随机数实现方法
- 项目里如何访问AppDelegate
- js中几种实用的跨域方法原理详解
- openssl之EVP
- NYOJ 题目42 一笔画问题(欧拉图)
- ViewStack 的自动创建子项策略 creationPolicy
- 分布式网站架构后续:zookeeper技术浅析
- 定制Android ListView 快速滚动的滚动条-fast scroll bar thumb
- php中函数前加&符号的作用分解
- 前端开发中常用的CSS选择器解析(一)
- Eclipse导出可运行的jar包,作为工具发布webService接口
- FSM之SMC使用总结
- Jquery文件提交
- 二次设置布局管理器的结果