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 ...
随机推荐
- Ajax 调用方式
function wds_generatecss() { var txt = $.trim($("#TxtText").val()); if (txt == "" ...
- Multiwii 代码解读
GPS部分 GPS_angle[ROLL] = (nav[LON]*cos_yaw_x - nav[LAT]*sin_yaw_y) /10;GPS_angle[PITCH] = (nav[LON ...
- android 布局常用混淆属性
1.如何控制某一控件在父控件中的相对位置呢? 在Android系统中提供了layout_margin,用来控制某一控件边缘相对于父控件的边距. 其中, android:layout_marginTop ...
- java调用C++ DLL库方法
最近一个项目要开发网页端人脸识别项目,人脸识别的算法已经写好,是C++版,但是网页端要求使用Java后台,这就涉及到Java调用DLL的问题.经过查找,实现了一个简单的例子. 1.第一步,先在Java ...
- 删除windows7保留分区
在系统里以管理员运行CMD.exe键入diskpartsel disk 0 (select 选择硬盘)list vol (查看卷)sel vol 0 (选择卷,0为保留分区)inactive ( ...
- 看日记学git摘要~灰常用心的教程
看日记学git linux 命令行 cd ls / ls -a clear mkdir rmdir echo "hi, good day" > hi.txt touch he ...
- python总结
环境:django,numpy,matplotlib, 解释语言:开发效率高,通用性强,内置方便的数据容器,易于扩展和嵌入. 语言:lua--嵌入式/网络/APP,erlang--嵌入式,python ...
- linux下mysql出现Access denied for user 'root'@'localhost' (using password: YES)解决方法
# /etc/init.d/mysql stop # mysqld_safe --user=mysql --skip-grant-tables --skip-networking & # my ...
- poj 1684 Lazy Math Instructor(字符串)
题目链接:http://poj.org/problem?id=1686 思路分析:该问题为表达式求值问题,对于字母使用浮点数替换即可,因为输入中的数字只能是单个digit. 代码如下: #includ ...
- Apple Catching(dp)
Apple Catching Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9831 Accepted: 4779 De ...