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 first 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 2 4 5该怎么办,这个算哪个错,然后我就不管不顾的写了代码,对了

#include<cstdio>
int main()
{
    int t,n,x,j,i,y;
    scanf("%d",&t);
    for(i=1;i<=t;i++)
    {
        scanf("%d",&n);
        scanf("%d",&x);
        int cnt=1;
        for(j=2;j<=n;j++)
        {
            scanf("%d",&y);
            if(y-x!=1)
            {
                cnt=j;
            }
            x=y;
        }
        printf("Case #%d: %d\n",i,cnt);
    }
    return 0;
}

同学写的就是考虑了我举得例子,他是按第一个是正确答案输出的

#include<stdio.h>
int main()
{
    int T,N,i,j,k,temp,cnt,flag;
    scanf("%d",&T);
    for(i=1;i<=T;i++)
    {
        scanf("%d",&N);
        scanf("%d",&temp);
        flag=cnt=1;
        for(j=2;j<=N;j++)
        {
            scanf("%d",&k);
            if(k-temp!=1&&flag)
                {cnt=j;flag=0;}
            temp=k;
        }
        printf("Case #%d: %d\n",i,cnt);
    }
    return 0;
}

这个应该很好理解吧,水题啊

The Number Off of FFF的更多相关文章

  1. 水题 HDOJ 4727 The Number Off of FFF

    题目传送门 /* 水题:判断前后的差值是否为1,b[i]记录差值,若没有找到,则是第一个出错 */ #include <cstdio> #include <iostream> ...

  2. 周赛-The Number Off of FFF 分类: 比赛 2015-08-02 09:27 3人阅读 评论(0) 收藏

    The Number Off of FFF Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...

  3. HDU 4727 The Number Off of FFF

    The Number Off of FFF Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...

  4. HDU 4727 The Number Off of FFF (水题)

    The Number Off of FFF Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  5. HDUOJ----The Number Off of FFF

    The Number Off of FFF Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  6. hdu4727 The Number Off of FFF

    理解错题意,wa了几次. 我一开始的理解忽略了实际背景,认为错报是绝对的,不依赖于其左边的人. 而实际上某士兵报数的对错取决且仅取决于他所报的数与其左邻所报的数. 所以假设第一个人没有报错,则其后必有 ...

  7. HDU-4727 The Number Off of FFF 水题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4727 水题.. //STATUS:C++_AC_187MS_288KB #include <fu ...

  8. HDU 4727 The Number Off of FFF 2013年四川省赛题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4727 题目大意:队列里所有人进行报数,要找出报错的那个人 思路:,只要找出序列中与钱一个人的数字差不是 ...

  9. 移除input number上的spinner

    HTML 5 的表单中有着丰富的input种类,比如说input[type="number"],就可以保证用户输入数字,但是input也有一些不好的地方——带有 spinner. ...

随机推荐

  1. mysql 查询成本

    SELECT SQL_NO_CACHE spu from dp_distributor_products_1_online where dpId > 15 AND dpId <= 60; ...

  2. 20145220&20145209&20145309信息安全系统设计基础实验报告(2)

    20145220&20145209&20145309信息安全系统设计基础实验报告(2) 实验报告链接: http://www.cnblogs.com/zym0728/p/6083664 ...

  3. js按键监听

    //回车键监听 function keypressed(){ if(event.keyCode == 13) { doAction(); } } document.onkeydown = keypre ...

  4. ORM系列之三:Dapper

    目录 1.Dapper 简介 2.Dapper 安装 3.Dapper 使用 Dapper简介 Dapper是一个轻量级的ORM框架,短小精悍,正如其名.对于小项目,使用EF,NHibernate这样 ...

  5. TCP协议学习笔记(一)首部以及TCP的三次握手连接四次挥手断开

    TCP协议是一种面向连接的.可靠的流协议. 流即不间断的数据结构.这样能够保证接收到数据顺序与发送相同.但是犹如数据间没有间隔,因此在TCP通信中,发送端应用可以在自己所要发送的消息中设置一个标示长度 ...

  6. AFNetworking 2.0指北

    AFNetworking 2.0 来了 SEP 30TH, 2013 前几天 Mattt 发布了 AFNetworking 2.0,我的一个最大感慨就是,他怎么那么高产? 关于 Mattt Mattt ...

  7. wp8.1 页面返回 页面导航

    public The_second() public second() { this.InitializeComponent(); Frame frame = Window.Current.Conte ...

  8. input只能输入数字并限制长度

    <style> /*在chrome下移除input[number]的上下箭头*/ input::-webkit-outer-spin-button,input::-webkit-inner ...

  9. Git 常见的一些小命令

        Git 常见的一些命令 关于一些参数比较多,比较复杂的都有单独进行介绍         1. git cherry-pick 挑拣命令,当我们不想合并分支,或者git pull 更新仓库,而是 ...

  10. Java提高篇——单例模式

    介绍 在我们日常的工作中经常需要在应用程序中保持一个唯一的实例,如:IO处理,数据库操作等,由于这些对象都要占用重要的系统资源,所以我们必须限制这些实例的创建或始终使用一个公用的实例,这就是我们今天要 ...