The Number Off of FFF

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 78    Accepted Submission(s): 36

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
 
Source
 
Recommend
zhuyuanchen520
 
 /* ***********************************************
Author :kuangbin
Created Time :2013-9-11 12:08:15
File Name :2013-9-11\1012.cpp
************************************************ */ #include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
int a[];
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int T;
int n;
scanf("%d",&T);
int iCase = ;
while(T--)
{
iCase++;
scanf("%d",&n);
for(int i = ;i < n;i++)
scanf("%d",&a[i]);
int ans = ;
for(int i = ;i < n;i++)
if(a[i] != a[i-] + )
{
ans = i+;
break;
}
printf("Case #%d: %d\n",iCase,ans);
}
return ;
}

HDU 4727 The Number Off of FFF (水题)的更多相关文章

  1. 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 ...

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

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

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

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

  4. 水题 HDOJ 4727 The Number Off of FFF

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

  5. HDU 5832 A water problem(某水题)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  6. hdu 2393:Higher Math(计算几何,水题)

    Higher Math Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  7. <hdu - 3999> The order of a Tree 水题 之 二叉搜索的数的先序输出

    这里是杭电hdu上的链接:http://acm.hdu.edu.cn/showproblem.php?pid=3999  Problem Description: As we know,the sha ...

  8. hdu 1164:Eddy's research I(水题,数学题,筛法)

    Eddy's research I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  9. HDOJ/HDU 1256 画8(绞下思维~水题)

    Problem Description 谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发. Input 输入的第一行为一个整数N,表示后面有N组数据. 每组数据中有一个字符和一 ...

随机推荐

  1. image配准,发布geoserver服务

    1.arcmap配准:注:png只保留需要显示范围,多余部分删除,,配准后再进行栅格裁剪(为了去除偏移后出现的NoData值) 2.导出tif:注:NoData值设置,一般为256(有时候经过裁剪会默 ...

  2. tf.nn.embedding_lookup函数

    tf.nn.embedding_lookup(params, ids, partition_strategy='mod', name=None, validate_indices=True, max_ ...

  3. Oracle 函数 “判断数据表中不存在的数据,才允许通过”

    create or replace function mca_detail_material_val(p_material_code VARCHAR2, --实参 p_material_name VA ...

  4. MySQL学习笔记:生成时间维度表2

    实现目的: 测试: # 测试 加一秒 SECOND), INTERVAL SECOND); SECOND),'%H%i%s');# 第一秒 SECOND),'%H%i%s');# 最后一秒 SELEC ...

  5. C#连接mariadb代码及方式

    不负责任的说MariaDb和MySQL很多都是通用的,因为来自同一个爹... 和MySQL连接方式差不多 首先配置好你的MariaDb,创建test数据库,在test里创建MyTable表,脚本如下( ...

  6. 微信小程序 跳一跳 外挂 C# winform源码

    昨天微信更新了,出现了一个小游戏“跳一跳”,玩了一下 赶紧还蛮有意思的 但纯粹是拼手感的,玩了好久,终于搞了个135分拿了个第一名,没想到过一会就被朋友刷下去了,最高的也就200来分把,于是就想着要是 ...

  7. 使用setsid替代nohup

    使用setsid替代nohup 使用 nohup 执行sudo -e时会有问题的.

  8. 基于 Laravel 开发博客应用系列 —— 项目必备软件安装

    1.概述 通过本项目我们将会构建一个简单.清爽.优雅的博客系统,以及维护管理该博客的后台. 本项目源码公开在GitHub上:https://github.com/ChuckHeintzelman/l5 ...

  9. 跟厂长学PHP7内核(一):发展史

    PHP1 1994年,一位名叫Rasmus lerdorf的兄台为了在网上展示自己的履历和网页流量的统计,用Perl开发了一套脚本,后来因与日俱增的需求无法得到满足,lerdorf便使用c语言进行了重 ...

  10. 深度学习基础系列(五)| 深入理解交叉熵函数及其在tensorflow和keras中的实现

    在统计学中,损失函数是一种衡量损失和错误(这种损失与“错误地”估计有关,如费用或者设备的损失)程度的函数.假设某样本的实际输出为a,而预计的输出为y,则y与a之间存在偏差,深度学习的目的即是通过不断地 ...