题目链接:hdu 4727 The Number Off of FFF
题目大意:有n个人,从左向右报数,找出第几个人数报错了。
解题思路:水题,特殊情况,大家都没错的时候是第一个人错。
#include <cstdio>
#include <cstring>
int main () {
int cas;
scanf("%d", &cas);
for (int i = 1; i <= cas; i++) {
int n, first, x, ans = 0;
scanf("%d%d", &n, &first);
for (int j = 1; j < n; j++) {
scanf("%d", &x);
if (ans)
continue;
if (x != first + j)
ans = j;
}
printf("Case #%d: %d\n", i, ans+1);
}
return 0;
}