HDU 5578 Friendship of Frog 暴力搜索
来源:互联网 发布:tk免费域名注册网站 编辑:程序博客网 时间:2024/04/29 04:43
思路~ 暴力搜索
第一次开了个数组存值结果TLE,后来改了直接搜索过程直接得出最小值AC
//#include <bits/stdc++.h>#include <cstdio>#include <iostream>#include <cstring>#include <cstdlib>#include <stack>#include <queue>#include <algorithm>#include <cmath>#include <vector>using namespace std;typedef long long ll;int main(){ int t,k; char a[1010]; int Min,count; scanf("%d",&t); count=0; while (t--) { scanf("%s",a); k=0; Min=9999; for (int i=0; i<strlen(a); i++) { for (int j=i+1; j<strlen(a); j++) { if(a[i]==a[j]){ Min=min(Min,j-i); } } } count++; if(strlen(a)==1){ printf("Case #%d: -1\n",count); } else if(Min==9999){ printf("Case #%d: -1\n",count); } else printf("Case #%d: %d\n",count,Min); } return 0;}
0 0
- HDU 5578 Friendship of Frog 暴力搜索
- HDU 5578 Friendship of Frog(暴力)
- HDU 5578 Friendship of Frog 暴力
- 文章标题 HDU 5578 :Friendship of Frog(暴力+map)
- hdu 5578 Friendship of Frog
- hdu 5578 Friendship of Frog
- hdu 5578 Friendship of Frog(水)
- hdu 5578 Friendship of Frog【水题】
- hdu 5578 Friendship of Frog 水题
- HDU 5578 Friendship of Frog(暴力)——2015ACM/ICPC亚洲区上海站
- Hdoj.5578 Friendship of Frog【字符串,暴力】 2015/12/04
- hdoj 5578 Friendship of Frog
- HDU-5578-Friendship of Frog【2015上海赛区】
- HDU-5578-Friendship of Frog【2015上海赛区】(水题)
- hdoj 5578 Friendship of Frog 【水题】
- Friendship of Frog
- hdu 5578 Friendship of Frog 2015ACM/ICPC亚洲区上海站-重现赛
- hdoj Friendship of Frog 5578 (简单字符串转换)
- 微信摇一摇-----加速度传感器的使用
- C#学习5
- int [] is an instance of Object
- Zookeeper应用 - Master选举
- PAT乙级(Basic Level)1009(Java)
- HDU 5578 Friendship of Frog 暴力搜索
- springmvc+mybatis框架学习总结
- HDU 4417 Super Mario
- sql优化之美
- 码神-java-day01-作业代码
- fastdfs分布式文件系统概述
- 1.Linux底层性能分析——概述及监控架构图
- C# 代码向MySQL 插入数据乱码问题
- 【深度学习】A neural algorithm of artistic style算法详解