您的位置:首页 > 其它

水题 HDOJ 4727 The Number Off of FFF

2015-04-19 20:24 393 查看
题目传送门

 /*
水题:判断前后的差值是否为1,b[i]记录差值,若没有找到,则是第一个出错
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 0x3f3f3f3f;
int a[MAXN];
int b[MAXN];

int main(void)        //HDOJ 4727 The Number Off of FFF
{
//freopen ("L.in", "r", stdin);

int t, cas = 0;
int n;
scanf ("%d", &t);
while (t--)
{
scanf ("%d", &n);

a[0] = b[0] = 0;
for (int i=1; i<=n; ++i)
{
scanf ("%d", &a[i]);
b[i] = a[i] - a[i-1];
}

int ans = -1;
for (int i=2; i<=n; ++i)
{
if (b[i] != 1)
{
ans = i;    break;
}
}
if (ans == -1)    ans = 1;

printf ("Case #%d: %d\n", ++cas, ans);
}

return 0;
}

/*
Case #1: 3
Case #2: 3
*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: