编程介的小学生 2017-08-16 09:07 采纳率: 20.5%
浏览 712
已采纳

He is Flying

Problem Description
JRY wants to drag racing along a long road. There are n sections on the road, the i-th section has a non-negative integer length si. JRY will choose some continuous sections to race (at an unbelievable speed), so there are totally n(n+1)2 different ways for him to ride. If JRY rides across from the i-th section to the j-th section, he would gain j−i+1 pleasure. Now JRY wants to know, if he tries all the ways whose length is s, what's the total pleasure he can get. Please be aware that in the problem, the length of one section could be zero, which means that the length is so trivial that we can regard it as 0.

Input
The first line of the input is a single integer T (T=5), indicating the number of testcases.

For each testcase, the first line contains one integer n. The second line contains n non-negative integers, which mean the length of every section. If we denote the total length of all the sections as s, we can guarantee that 0≤s≤50000 and 1≤n≤100000.

Output
For each testcase, print s+1 lines. The single number in the i-th line indicates the total pleasure JRY can get if he races all the ways of length i−1.

Sample Input
2
3
1 2 3
4
0 1 2 3

Sample Output
0
1
1
3
0
2
3
1
3
1
6
0
2
7

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-08-16 15:40
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘