HDU 4727 The Number Off of FFF
来源:互联网 发布:百度软件开发工程师 编辑:程序博客网 时间:2024/06/05 08:09
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.
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.
231 2 431001 1002 1004
Case #1: 3Case #2: 3
奇怪的题目,总感觉题目是有问题的,对于第一个点的判断太奇怪了。
#include<map> #include<set> #include<ctime> #include<cmath> #include<stack>#include<queue> #include<string> #include<vector> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<functional> using namespace std;#define ms(x,y) memset(x,y,sizeof(x)) #define rep(i,j,k) for(int i=j;i<=k;i++) #define per(i,j,k) for(int i=j;i>=k;i--) #define loop(i,j,k) for (int i=j;i!=-1;i=k[i]) #define inone(x) scanf("%d",&x) #define intwo(x,y) scanf("%d%d",&x,&y) #define inthr(x,y,z) scanf("%d%d%d",&x,&y,&z) #define infou(x,y,z,p) scanf("%d%d%d%d",&x,&y,&z,&p) #define lson x<<1,l,mid #define rson x<<1|1,mid+1,r #define mp(i,j) make_pair(i,j) #define ff first #define ss second typedef long long LL;typedef pair<int, int> pii;const int low(int x) { return x&-x; }const int INF = 0x7FFFFFFF;const int mod = 1e9 + 7;const int N = 1e5 + 10;const double eps = 1e-10;int T, n, cas = 1, a[N];int main(){for (inone(T); T--; cas++){inone(n);rep(i, 1, n) inone(a[i]);printf("Case #%d: ", cas);int flag = 0;rep(i, 2, n){if (a[1] + i - 1 != a[i]){printf("%d\n", i);flag = 1; break;}}if (!flag) puts("1");}return 0;}
0 0
- hdu 4727 The Number Off of FFF
- Hdu 4727 The Number Off of FFF
- HDU 4727 The Number Off of FFF
- HDU 4727 The Number Off of FFF
- HDU 4727 The Number Off of FFF
- HDU 4727 The Number Off of FFF
- HDU 4727 The Number Off of FFF
- HDU 4727-The Number Off of FFF
- HDU 4727 The Number Off of FFF
- HDU 4727 The Number Off of FFF
- hdu The Number Off of FFF
- HDU 4727 The Number Off of FFF (水题)
- HDU 4727 The Number Off of FFF 解题报告
- hdu 4727 The Number Off of FFF(遍历)
- hdu 4727 The Number Off of FFF(模拟)
- HDU 4727 The Number Off of FFF(水题)
- 【HDU 4727 】【水题】The Number Off of FFF
- HDU 4727 The Number Off of FFF (水)
- 在finalize方法中复活java对象
- qt中“无法启动此程序,因为计算机丢失缺少Qt5.Core.dll”
- 创建web service proxy错误未知类型参考ns1
- Log4j教程
- 关于最长公共子序列(SIM核心算法)
- HDU 4727 The Number Off of FFF
- opencv入门学习之七:罗伯特Robert变换和Sobel变换锐化图像
- Log4j学习总结
- [Leetcode] #200 Number of Islands
- 互信息和信息熵
- [leetcode]230. Kth Smallest Element in a BST
- 飞花的糖果
- 注解框架---AndroidAnnotations
- poj 1150 The Last Non-zero Digit(阶乘取模运算的简单性质及递归技巧)