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/Others)
Total Submission(s): 602 Accepted Submission(s): 284
*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.
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 <= 10
5)
It guaranteed that there is exactly one soldier who has made the mistake.
3
1 2 4
3
1001 1002 1004
Case #2: 3
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
int t,n;
long[] a;
public static void main(String[] args) throws IOException{
new Main().work();
}
void work() throws IOException{
BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw=new PrintWriter(new OutputStreamWriter(System.out),true);
t=Integer.parseInt(bu.readLine()); for(int p=1;p<=t;p++){
pw.print("Case #"+p+": ");
n=Integer.parseInt(bu.readLine());
a=new long[n];
String str[]=bu.readLine().split(" ");
for(int i=0;i<n;i++){
a[i]=Long.parseLong(str[i]);
} long i=a[0];
boolean boo=true; for(int j=0;j<n;j++,i++){
if(i!=a[j]){
pw.println(j+1);
boo=false;
break;
}
}
if(boo)
pw.println(1);
}
}
}
HDU 4727 The Number Off of FFF的更多相关文章
- 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 ...
- HDU 4727 The Number Off of FFF 2013年四川省赛题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4727 题目大意:队列里所有人进行报数,要找出报错的那个人 思路:,只要找出序列中与钱一个人的数字差不是 ...
- 水题 HDOJ 4727 The Number Off of FFF
题目传送门 /* 水题:判断前后的差值是否为1,b[i]记录差值,若没有找到,则是第一个出错 */ #include <cstdio> #include <iostream> ...
- hdu 5898 odd-even number 数位DP
传送门:hdu 5898 odd-even number 思路:数位DP,套着数位DP的模板搞一发就可以了不过要注意前导0的处理,dp[pos][pre][status][ze] pos:当前处理的位 ...
- 周赛-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 ...
- hdu 2665 Kth number
划分树 /* HDU 2665 Kth number 划分树 */ #include<stdio.h> #include<iostream> #include<strin ...
- hdu 4670 Cube number on a tree(点分治)
Cube number on a tree Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/ ...
- 主席树[可持久化线段树](hdu 2665 Kth number、SP 10628 Count on a tree、ZOJ 2112 Dynamic Rankings、codeforces 813E Army Creation、codeforces960F:Pathwalks )
在今天三黑(恶意评分刷上去的那种)两紫的智推中,突然出现了P3834 [模板]可持久化线段树 1(主席树)就突然有了不详的预感2333 果然...然后我gg了!被大佬虐了! hdu 2665 Kth ...
- 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 ...
随机推荐
- [C#参考]利用Socket连续发送数据
这个例子只是一个简单的连续发送数据,接收数据的DEMO.因为最近做一个项目,要求robot连续的通过Socket传回自己的当前的位置坐标,然后客户端接收到坐标信息,在本地绘制地图,实时显示robot的 ...
- jQuery Validate W3C内容
导入 js 库 <script src="../js/jquery.js" type="text/javascript"></script&g ...
- Hadoop2.0安装
http://blog.csdn.net/samhacker/article/details/18802223 http://blog.csdn.net/crazyhacking/article/de ...
- iOS6与iOS7屏幕适配技巧
一.没有包装任何 导航控制器 或者 UITabBarController 1.控制器的view是UIScrollView\UITableView\UICollectionView时(控制器是UITab ...
- 狼追兔子问题C模拟解
说,一只兔子在O点处,它的洞穴在正北20m的B点处,一只狼位于兔子正东33米的A点处,模拟如下追逐问题:狼以一倍于兔子的速度紧盯兔子追击,问兔子到达洞口前是否会被狼逮住? 网上很多人说能被追上,包括类 ...
- linux c 通过文件描写叙述符获取文件名称
在linux中每一个被打开的文件都会在/proc/self/fd/文件夹中有记录,当中(/proc/self/fd/文件描写叙述符号:这个文件是符号文件)的文件就是文件描写叙述符所相应的文件. 而re ...
- HTML系列(一):创建HTML文档
从本学期开始我打算把我以前学的知识点系统地总结一下,先从HTML开始.(本系列内容总结自博文视点出版社•代码逆袭系列书籍,包括代码片段.) 一.HTML文档类型 HTML版本众多,浏览器如何得知使用的 ...
- 简单的web三层架构系统【第二版】
昨天写了 web三层架构的第一版,准确的说是三层架构的前期,顶多算是个二层架构,要慢慢完善. 第一版里,程序虽说能运行起来,但是有一个缺陷,就是里面的SQL语句,是使用的拼接字符进行执行.这样安全系数 ...
- ASP.NET MVC导入excel到数据库
MVC导入excel和webform其实没多大区别,以下为代码: 视图StationImport.cshtml的代码: @{ ViewBag.Title = "StationImport&q ...
- ReportViewer动态加载数据源
ReportViewer主要用于打印和导出数据到pdf或excel,接下来将简单做一张Northwind的Products表的统计报表. (最终图) 一.新建一张报表 二.添加数据集 添加xsd文件后 ...