本文主要是介绍hdu 5578 Friendship of Frog(水),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目链接: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;
}
这篇关于hdu 5578 Friendship of Frog(水)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!