编程介的小学生 2019-08-06 21:57 采纳率: 20.5%
浏览 183

根据公式的计算的一个算法的问题,怎么用C语言来实现

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
    • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
    • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
    • ¥15 乘性高斯噪声在深度学习网络中的应用
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛