Here N (N ≥ 3) rabbits are playing by the river. They are playing on a number line, each occupying a different integer. In a single move, one of the outer rabbits jumps into a space between any other two. At no point may two rabbits occupy the same position. 
Help them play as long as possible

InputThe input has several test cases. The first line of input contains an integer t (1 ≤ t ≤ 500) indicating the number of test cases. 
For each case the first line contains the integer N (3 ≤ N ≤ 500) described as above. The second line contains n integers a1a1 < a2a2 < a3a3 < ... < aNaN which are the initial positions of the rabbits. For each rabbit, its initial position 
aiai satisfies 1 ≤ aiai ≤ 10000. 
OutputFor each case, output the largest number of moves the rabbits can make. 
Sample Input

5
3
3 4 6
3
2 3 5
3
3 5 9
4
1 2 3 4
4
1 2 4 5

Sample Output

1
1
3
0
1
签到题:Orz
 #include<bits/stdc++.h>
using namespace std;
int T,num[],sum[];
int main()
{
scanf("%d",&T);
while(T--)
{
int n;
scanf("%d",&n);
int len=;
for(int i=;i<=n;i++) scanf("%d",&num[i]);
for(int i=;i<n;i++) sum[i]=num[i+]-num[i]-,len+=sum[i];
int ans=len-min(sum[],sum[n-]);
printf("%d\n",ans);
}
return ;
}

  

2017 ACM/ICPC 沈阳 K题 Rabbits的更多相关文章

  1. 2017 ACM/ICPC 沈阳 L题 Tree

    Consider a un-rooted tree T which is not the biological significance of tree or plant, but a tree as ...

  2. 2017 ACM/ICPC 沈阳 I题 Little Boxes

    Little boxes on the hillside. Little boxes made of ticky-tacky. Little boxes. Little boxes. Little b ...

  3. 2017 ACM/ICPC 沈阳 F题 Heron and his triangle

    A triangle is a Heron’s triangle if it satisfies that the side lengths of it are consecutive integer ...

  4. 2017 ACM/ICPC 沈阳 G题 Infinite Fraction Path

    The ant Welly now dedicates himself to urban infrastructure. He came to the kingdom of numbers and s ...

  5. 2017 ACM/ICPC Asia Regional Qingdao Online

    Apple Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submi ...

  6. 2017 ACM/ICPC Asia Regional Shenyang Online spfa+最长路

    transaction transaction transaction Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 132768/1 ...

  7. 2017 ACM ICPC Asia Regional - Daejeon

    2017 ACM ICPC Asia Regional - Daejeon Problem A Broadcast Stations 题目描述:给出一棵树,每一个点有一个辐射距离\(p_i\)(待确定 ...

  8. 2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest

    2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest A - Arranging Wine 题目描述:有\(R\)个红箱和\(W\)个白箱,将这 ...

  9. 2017 ACM/ICPC Shenyang Online SPFA+无向图最长路

    transaction transaction transaction Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 132768/1 ...

随机推荐

  1. java VS c#,异同点

    因工作安排,后期需要维护一个java项目.所以稍微熟悉下java,开此篇记录下java与c#的区别点,方便增强自己学习效果.肯定是不全的,可能是有错的,欢迎批评指正. 一.关键字 描述 C# Java ...

  2. js常用的array方法

      1. splice() splice()方法向/从数组中添加/删除项目,然后返回被删除的项目.(注释:该方法会改变原始数组.) arrayObject.splice(index,howmany,i ...

  3. Comet OJ - Contest #10 C题 鱼跃龙门

    ###题目链接### 题目大意: 给你一个 x ,让你求出最小的正整数 n 使得 n * (n + 1) / 2  % x == 0 ,即 n * (n + 1)  % 2x == 0 . 分析: 1 ...

  4. 为企业应用开发提速,写给企业IT部门的低代码开发基础知识

    简介:应用程序开发长期以来一直是IT部门和业务部门面临的问题. IT部门总是被新的应用程序需求弄得不堪重负.他们不可能完成业务部门想要完成的每一个项目. 同时,业务部门的用户厌倦了等待,并开始完全绕过 ...

  5. QQ是怎样创造出来的?——解密好友系统的设计

    本篇介绍笔者接触的第一个后台系统,从自身见闻出发,因此涉及的内容相对比较基础,后台大牛请自觉略过. 什么是好友系统? 简单的说,好友系统是维护用户好友关系的系统.我们最熟悉的好友系统案例当属QQ,实际 ...

  6. 安装win7和ubuntu16.04双系统

    硬件:2012年本子  话硕A55V Service 准备: 首先通过一键还原备份win7系统!不清楚某些失误会不会备份也不能拯救! 清出100g硬盘空间,ubuntu会安装在这里 查看当前win7启 ...

  7. Linux网络配置文件

    centos为例: /etc/sysconfig/network文件 用于基本的网络配置信息,包含了控制和网络有关的文件和守护进程的行为参数,包括主机名.网关等 (默认:我的cent0s7在为空,fe ...

  8. python CGI编程-----简单的本地使用(1)

    本章节需要安装python开发工具,window平台安装地址:https://www.python.org/downloads/windows/,linux安装地址:https://www.pytho ...

  9. Maven入门【小白千万别点进】

    曾经有个女孩问我为什么要学Maven,我吧唧嘴就怼:Maven项目没有jar包它不香嘛,照样运行它不香嘛?如果让我一句话形容Maven,我会这样形容:"妈妈再也不用担心小明拿U盘去小红电脑里 ...

  10. day 13 生成器函数 表达式 推导式

    今日主要内容 1. 生成器和生成器函数 生成器的本质就是迭代器 生成器的三种创建办法: 1.通过生成器函数 2.通过生成器表达式创建生成器 3.通过数据转换 2. 生成器函数: 函数中包含了yield ...