The Number Off of FFF

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 2813 Accepted Submission(s): 935

Problem Description

X soldiers from the famous “FFF army” is standing in a line, from left to right.

You, as the captain of FFF, decides to have a “number off”, that is, each soldier, from left to right, calls out a number. The first soldier should call “One”, each other soldier should call the number next to the number called out by the soldier on his left side. If every soldier has done it right, they will call out the numbers from 1 to X, one by one, from left to right.

Now we have a continuous part from the original line. There are N soldiers in the part. So in another word, we have the soldiers whose id are between A and A+N-1 (1 <= A <= A+N-1 <= X). However, we don’t know the exactly value of A, but we are sure the soldiers stands continuously in the original line, from left to right.

We are sure among those N soldiers, exactly one soldier has made a mistake. Your task is to find that soldier.

Input

The rst line has a number T (T <= 10) , indicating the number of test cases.

For each test case there are two lines. First line has the number N, and the second line has N numbers, as described above. (3 <= N <= 105)

It guaranteed that there is exactly one soldier who has made the mistake.

Output

For test case X, output in the form of “Case #X: L”, L here means the position of soldier among the N soldiers counted from left to right based on 1.

Sample Input

2

3

1 2 4

3

1001 1002 1004

Sample Output

Case #1: 3

Case #2: 3

简单题,注意细节

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <list>
#include <algorithm>
#define LL long long
#define RR freopen("output.txt","r",stdoin)
#define WW freopen("input.txt","w",stdout) using namespace std; const int MAX = 100100; int main()
{
int T;
int n,a,m;
int flag;
int w=1;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
flag=0;
for(int i=0;i<n;i++)
{
scanf("%d",&a);
if(flag)
{
continue;
}
if(i==0)
{
m=a+1;
}
else
{
if(m==a)
{
m++;
}
else
{
flag=i+1;
}
}
}
printf("Case #%d: ",w++);
if(flag)
{
printf("%d\n",flag);
}
else
{
printf("1\n");
}
} return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

周赛-The Number Off of FFF 分类: 比赛 2015-08-02 09:27 3人阅读 评论(0) 收藏的更多相关文章

  1. Retinex系列之McCann99 Retinex 分类: 图像处理 Matlab 2014-12-03 11:27 585人阅读 评论(0) 收藏

    一.McCann99 Retinex McCann99利用金字塔模型建立对图像的多分辨率描述,自顶向下逐层迭代,提高增强效率.对输入图像的长宽有 严格的限制,要求可表示成 ,且 ,. 上述限制来源于金 ...

  2. 随机L系统分形树 分类: 计算机图形学 2014-06-01 23:27 376人阅读 评论(0) 收藏

    下面代码需要插入到MFC项目中运行,实现了计算机图形学中的L系统分形树. class Node { public: int x,y; double direction; Node(){} }; CSt ...

  3. Hdu 1507 Uncle Tom's Inherited Land* 分类: Brush Mode 2014-07-30 09:28 112人阅读 评论(0) 收藏

    Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (J ...

  4. PIGS 分类: POJ 图论 2015-08-10 09:15 3人阅读 评论(0) 收藏

    PIGS Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18209 Accepted: 8277 Description Mir ...

  5. Poj 2528 Mayor's posters 分类: Brush Mode 2014-07-23 09:12 84人阅读 评论(0) 收藏

    Mayor's posters Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 40570   Accepted: 11798 ...

  6. Poj 2349 Arctic Network 分类: Brush Mode 2014-07-20 09:31 93人阅读 评论(0) 收藏

    Arctic Network Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9557   Accepted: 3187 De ...

  7. iOS开源库--最全的整理 分类: ios相关 2015-04-08 09:20 486人阅读 评论(0) 收藏

    youtube下载神器:https://github.com/rg3/youtube-dl 我擦咧 vim插件:https://github.com/Valloric/YouCompleteMe vi ...

  8. Jquery easy UI 上中下三栏布局 分类: ASP.NET 2015-02-06 09:19 368人阅读 评论(0) 收藏

    效果图: 源代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://w ...

  9. C# IIS应用程序池辅助类 分类: C# Helper 2014-07-19 09:50 249人阅读 评论(0) 收藏

    using System.Collections.Generic; using System.DirectoryServices; using System.Linq; using Microsoft ...

随机推荐

  1. iptables使用

    iptables规则的查看.添加.删除和修改 1.查看 iptables -nvL --line-number (这个命令跟/etc/init.d/iptables status 输出差不多) -L ...

  2. 如何不切换windows登陆用户,更换用户名访问共享文件夹

    @echo offnet use * /del /ynet use \\192.168.2.1 /user:wr@echo off 先进行删除所有,然后在进行映射,按照部门来,不同的部门可能需要映射的 ...

  3. zepto和jquery的区别,zepto的不同使用8条小结 会JS就会zepto

    1. Zepto 对象 不能自定义事件 例如执行: $({}).bind('cust', function(){}); 结果:  TypeError: Object has no method 'ad ...

  4. Java基础(47):插入排序的Java封装(含原理,可运行,哨兵位的理解见VisualGo上面的动态分析)

    直接插入排序(Straight Insertion Sorting)的基本思想:在要排序的一组数中,假设前面(n-1) [n>=2] 个数已经是排好顺序的,现在要把第n个数插到前面的有序数中,使 ...

  5. bzoj 4358 permu

    比较容易想到莫队算法+线段树,但是这样时间复杂度是O(nsqrtnlogn)无法通过,考虑如果不进行删除操作,只有添加操作的话那么并查集就可以实现了,于是可以设定sqrtn块,每个块范围为(i-1)* ...

  6. CCF真题之相反数

    201403-1 问题描述 有 N 个非零且各不相同的整数.请你编一个程序求出它们中有多少对相反数(a 和 -a 为一对相反数). 输入格式 第一行包含一个正整数 N.(1 ≤ N ≤ 500).   ...

  7. spark读取hdfs数据本地性异常

    在分布式计算中,为了提高计算速度,数据本地性是其中重要的一环. 不过有时候它同样也会带来一些问题. 一.问题描述 在分布式计算中,大多数情况下要做到移动计算而非移动数据,所以数据本地性尤其重要,因此我 ...

  8. 夺命雷公狗---DEDECMS----19dedecms栏目列表页的完成

    我们的栏目页表页的模版如果不清楚叫什么名,可以通过: 这里很清楚的记录着,我们来看下他: 他长得和我们以前做首页时候是不是很像呢?其实就是一样的,我们改下即可,如下所示: {dede:channel ...

  9. php文件上传参数设置

    php默认的 上传文件大小是2M,要上传超过此大小的文件,需要设置php和apache的一些参数,具体参考如下: 1.file_uploads:是否允许通过HTTP上传文件的开关,默认为ON就是开 2 ...

  10. Ceph的集群全部换IP

    由于要对物理机器要做IP规划,所有物理机统一做到35网段,对于ceph集群来说,是有一定工作量的. 前提条件,ceph集群正常.原来的所有集群在44网段.mon地址是172.17.44.22 在44网 ...