HDU 6227.Rabbits-规律 (2017ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学))
Rabbits
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 1193 Accepted Submission(s): 628
Help them play as long as possible
For each case the first line contains the integer N (3 ≤ N ≤ 500) described as above. The second line contains n integers a1 < a2 < a3 < ... < aN which are the initial positions of the rabbits. For each rabbit, its initial position
ai satisfies 1 ≤ ai ≤ 10000.
1 #include<bits/stdc++.h>
2 using namespace std;
3 const int N=1e5+10;
4 const int INF=0x3f3f3f3f;
5 int flag[N];
6 int a[N];
7 int main(){
8 int t,n,minn;
9 int num1,num2,num;
10 while(~scanf("%d",&t)){
11 while(t--){
12 scanf("%d",&n);
13 memset(flag,0,sizeof(flag));
14 for(int i=0;i<n;i++){
15 scanf("%d",&a[i]);
16 flag[a[i]]=1;
17 }
18 num1=0,num2=0,num=0;
19 for(int i=a[0];i<=a[1];i++){
20 if(flag[i]==0)num1++;
21 }
22 for(int i=a[n-2];i<=a[n-1];i++){
23 if(flag[i]==0)num2++;
24 }
25 for(int i=a[0];i<=a[n-1];i++){
26 if(flag[i]==0)num++;
27 }
28 //cout<<num1<<" "<<num2<<" "<<num<<endl;
29 minn=min(num1,num2);
30 printf("%d\n",num-minn);
31 }
32 }
33 return 0;
34 }
HDU 6227.Rabbits-规律 (2017ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学))的更多相关文章
- HDU 6225.Little Boxes-大数加法 (2017ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学))
整理代码... Little Boxes Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/O ...
- 2017ACM/ICPC亚洲区沈阳站-重现赛
HDU 6222 Heron and His Triangle 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6222 思路: 打表找规律+大数运算 首先我 ...
- 2017ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学)
Little Boxes Problem Description Little boxes on the hillside.Little boxes made of ticky-tacky.Littl ...
- 2016ACM/ICPC亚洲区沈阳站-重现赛赛题
今天做的沈阳站重现赛,自己还是太水,只做出两道签到题,另外两道看懂题意了,但是也没能做出来. 1. Thickest Burger Time Limit: 2000/1000 MS (Java/Oth ...
- hdu 5510 Bazinga (kmp+dfs剪枝) 2015ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学)
废话: 这道题很是花了我一番功夫.首先,我不会kmp算法,还专门学了一下这个算法.其次,即使会用kmp,但是如果暴力枚举的话,还是毫无疑问会爆掉.因此在dfs的基础上加上两次剪枝解决了这道题. 题意: ...
- 2016ACM/ICPC亚洲区沈阳站-重现赛
C.Recursive sequence 求ans(x),ans(1)=a,ans(2)=b,ans(n)=ans(n-2)*2+ans(n-1)+n^4 如果直接就去解...很难,毕竟不是那种可以直 ...
- 2015ACM/ICPC亚洲区沈阳站重现赛-HDU5512-Pagodas-gcd
n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, l ...
- 2015ACM/ICPC亚洲区沈阳站-重现赛 M - Meeting (特殊建边,最短路)
题意:有\(n\)个点,\(m\)个集合,集合\(E_i\)中的点都与集合中的其它点有一条边权为\(t_i\)的边,现在问第\(1\)个点和第\(n\)个点到某个点的路径最短,输出最短路径和目标点,如 ...
- 2015ACM/ICPC亚洲区沈阳站-重现赛 B - Bazinga (KMP)
题意:给你\(n\)个字符串,\(s_1,s_2,...,s_n\),对于\(i(1\le i\le n)\),找到最大的\(i\),并且满足\(s_j(1\le j<i)\)不是\(s_i\) ...
随机推荐
- loj6392 「THUPC2018」密码学第三次小作业 / Rsa
还是挺好做的,\((e_1,e_2)=1 \Rightarrow e_1s+e_2t=0\),\(m \equiv m^1 \equiv m^{e_1s+e_2t} \equiv c_1^s c_2^ ...
- jxl教程图文详解
近来学习了下jxl的操作Excel报表功能,现有的API基本可以满足当前的需要,抽空做了一个学生成绩查询报表的例子. 先看效果图: 从图中可以看到这是一个交叉报表,横向到Q列,纵向有22行,全部是通过 ...
- WampServer配置说明
注意:所有的修改操作都要重启WampServer服务器,部分需要重启WampServer软件 1.修改默认端口 1)打开文件:C:\wamp\bin\apache\apache2.4.9\conf\h ...
- 【Sudoku Solver】cpp
题目: Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated b ...
- ArrayList以及Map小练
ArrayList常用方法 public static void main(String[] args) { List list = new ArrayList(); List list1 = new ...
- icpc南昌邀请赛 比赛总结
上周末,我参加了icpc南昌区域赛邀请赛,这也是我的第一次外出参赛. 星期五晚上,在6个小时的火车和1个小时的公交后,我们终于抵达了江西师范大学,这次的比赛场地.江西师范大学周围的设施很齐全,各种烧烤 ...
- Git 笔记 - section 1
1. 创建版本库 创建目录 git init git add <file> git commit -m "本次提交内容的说明" 2. 查看状态 git status g ...
- UVALive 5987
求第n个数,该数满足至少由3个不同的素数的乘机组成 #include #include #include #include #include using namespace std; int prim ...
- 12c可插拔数据库CDB与PDB管理总结
12c可插拔数据库CDB与PDB管理总结 创建pdb1.直接创建 CREATE PLUGGABLE DATABASE pdb2 ADMIN USER boswll IDENTIFIED BY orac ...
- 【bzoj5018】[Snoi2017]英雄联盟 背包dp
题目描述 正在上大学的小皮球热爱英雄联盟这款游戏,而且打的很菜,被网友们戏称为「小学生」.现在,小皮球终于受不了网友们的嘲讽,决定变强了,他变强的方法就是:买皮肤!小皮球只会玩N个英雄,因此,他也只准 ...