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

简单题,注意细节

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstdlib>
  4. #include <cstring>
  5. #include <cmath>
  6. #include <queue>
  7. #include <stack>
  8. #include <map>
  9. #include <list>
  10. #include <algorithm>
  11. #define LL long long
  12. #define RR freopen("output.txt","r",stdoin)
  13. #define WW freopen("input.txt","w",stdout)
  14. using namespace std;
  15. const int MAX = 100100;
  16. int main()
  17. {
  18. int T;
  19. int n,a,m;
  20. int flag;
  21. int w=1;
  22. scanf("%d",&T);
  23. while(T--)
  24. {
  25. scanf("%d",&n);
  26. flag=0;
  27. for(int i=0;i<n;i++)
  28. {
  29. scanf("%d",&a);
  30. if(flag)
  31. {
  32. continue;
  33. }
  34. if(i==0)
  35. {
  36. m=a+1;
  37. }
  38. else
  39. {
  40. if(m==a)
  41. {
  42. m++;
  43. }
  44. else
  45. {
  46. flag=i+1;
  47. }
  48. }
  49. }
  50. printf("Case #%d: ",w++);
  51. if(flag)
  52. {
  53. printf("%d\n",flag);
  54. }
  55. else
  56. {
  57. printf("1\n");
  58. }
  59. }
  60. return 0;
  61. }

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

周赛-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. SqlServer常用命令

    dbcc showfilestats 显示数据库空间占用情况 sp_spaceused tb_Test 显示表占用情况 如果包含有非dbo的Scheme,需要特殊处理,比如我们表tb_Test所使用的 ...

  2. G面经Prepare: Search word delete sequence in dictionary

    给一个单词一个字典,每次删除单词里任一个字母直到剩下一个字母,形成一个序列,比如office->offce->ofce->ofc->oc->c.问是否字典里存在一个这种序 ...

  3. 转:Java实现几种常见排序方法

    日常操作中常见的排序方法有:冒泡排序.快速排序.选择排序.插入排序.希尔排序,甚至还有基数排序.鸡尾酒排序.桶排序.鸽巢排序.归并排序等. 冒泡排序是一种简单的排序算法.它重复地走访过要排序的数列,一 ...

  4. 转:python webdriver API 之对话框处理

    页面上弹出的对话框是自动化测试经常会遇到的一个问题:很多情况下对话框是一个 iframe,如上一节中介绍的例子,处理起来稍微有点麻烦:但现在很多前端框架的对话框是 div 形式的,这就让我们的处理变得 ...

  5. vs2003打包

    怎样将.Net程序部署到没有安装.Net Framwork的机器上? 部署在.Net 平台下开发的应用程序,需要安装安装对应版本的.Net Framwork,而Vsual Studio 2003并没有 ...

  6. c++的用处

    C++准确说是一门中级语言,介于汇编和高级语言之间吧,要求程序员了解计算机的内部数据存储.个人认为,作为学生还是花功夫学C++,因为<设计模式><数据结构>这些课程基本上还是C ...

  7. 3D语音天气球(源码分享)——在Unity中使用Android语音服务

    转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! 开篇废话: 这个项目准备分四部分介绍: 一:创建可旋转的"3D球":3 ...

  8. php文件上传参数设置

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

  9. How to change Jenkins default folder on Windows?

    http://stackoverflow.com/questions/12689139/how-to-change-jenkins-default-folder-on-windows accepted ...

  10. setTimeout() 与 setInterval()

    setTimeout() 从载入后延迟指定的时间去执行一个表达式或者是函数;       仅执行一次 ;和window.clearTimeout一起使用. setInterval() 在执行时,它从载 ...