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. 分析-eclipse已经导入jar包了,但还是出现classNotFound异常

    场景:分析-eclipse已经导入jar包了,但还是出现classNotFound异常 分析--eclipse已经导入jar包了,但还是出现classNotFound错误 最近在做一个web项目时,由 ...

  2. 总结-java

    Java核心技术总结 1.借用jar包编译java文件 javac -cp servlet-api.jar -d . HelloServlet.java

  3. Elasticsearch问题总结

    1.ES大量做FULL GC,日志如下: [2016-12-15 14:53:21,496][WARN ][monitor.jvm ] [vsp4] [gc][old][94725][4389] du ...

  4. selenium RC+JAVA 运行所遇到的问题

    1.报错一 Failed to start new browser session: java.lang.RuntimeException: Firefox 3 could not be found ...

  5. LightOj 1298 - One Theorem, One Year(DP + 欧拉)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1298 题意:给你两个数 n, p,表示一个数是由前 k 个素数组成的,共有 n 个素数 ...

  6. 【leedcode】longest-substring-without-repeating-characters

    Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...

  7. 实时控制软件设计第一周作业-汽车ABS软件系统案例分析

    汽车ABS软件系统案例分析 ABS 通过控制作用于车轮制动分泵上的制动管路压力,使汽车在紧急刹车时车轮不会抱死,这样就能使汽车在紧急制动时仍能保持较好的方向稳定性. ABS系统一般是在普通制动系统基础 ...

  8. Node.js 学习笔记

    时间:2016-07-07 提前安装好linux CentOs环境,以及相关工具(git,wget,vim……) 1.安装: 目前打算在CentOs上进行操作,网上有教程是旧的地址,这个是搬家后的新地 ...

  9. PhpStorm 4.0 & 5.0 部署本地Web应用 (转)

    1.创建新的项目(project),创建完成之后单击工具栏的应用运行/调试(Select Run/Debug Configuration)的下拉菜单弹出 Edit Cofigurations选项,单击 ...

  10. Timusoj 1982. Electrification Plan

    http://acm.timus.ru/problem.aspx?space=1&num=1982 1982. Electrification Plan Time limit: 0.5 sec ...