您的位置:首页 > 其它

hdu 5578 Friendship of Frog(水)

2015-12-03 20:59 351 查看
题目链接:hdu 5578 Friendship of Frog

代码

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int maxn = 1005;
const int inf = 0x3f3f3f3f;

char str[maxn];

int main () {
int cas;
scanf("%d", &cas);
for (int kcas = 1; kcas <= cas; kcas++) {
scanf("%s", str);
int n = strlen(str), ans = inf;
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++) if (str[i] == str[j])
ans = min(ans, j - i);
if (ans == inf) ans = -1;
printf("Case #%d: %d\n", kcas, ans);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: