HDU 2577 How to Type DP .
来源:互联网 发布:js实现旋转 编辑:程序博客网 时间:2024/04/30 18:47
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2577
因为就一维DP表示前i个最小距离具有后效性,所以再开一维表示是否开了caps lock就好了
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<cctype>using namespace std;const int maxn=100+5;const int INF=0x3f3f3f3f;const int O=1,C=0; char str[maxn];int d[maxn][2];//d[i][j] 表示前i个字符 且有没有开caps lock的最小编辑距离 int main(){int T,i; cin>>T;while(T--){scanf("%s",str+1);memset(d,INF,sizeof(INF));d[0][C]=0; d[0][O]=1;for(i=1;str[i];i++){if(isupper(str[i])){ //Big letterd[i][C]=min(d[i-1][O]+2,d[i-1][C]+2);d[i][O]=min(d[i-1][O]+1,d[i-1][C]+2);}else {d[i][C]=min(d[i-1][O]+2,d[i-1][C]+1);d[i][O]=min(d[i-1][O]+2,d[i-1][C]+3);}}cout<<min(d[i-1][O]+1,d[i-1][C])<<endl;}return 0;}
0 0
- HDU 2577 How To Type DP
- hdu 2577 How to Type(DP)
- hdu 2577 How to Type(DP)
- HDU 2577 How to Type (dp)
- HDU 2577 How to Type(dp)
- 【DP】HDU 2577 How to Type
- HDU-2577 How to Type DP
- hdu 2577 How to Type (dp)
- 【DP|水】HDU-2577 How to Type
- HDU 2577 How to Type (dp)
- hdu 2577 How to Type(dp)
- HDU 2577 How to Type (线性dp)
- hdu 2577 How to Type(DP)
- hdu 2577 How to Type dp
- [HDU 2577 How to Type]DP
- HDU 2577 How to Type(DP)
- HDU 2577 How to Type DP
- hdu 2577 How to Type (dp)
- strpos中needle为数字时会怎么样
- 为什么我们需要PRINCE2认证——上海信息化培训中心
- python字典按键或值排序
- spark-shell无法退格/删除
- 最大连续字串和与最大连续子串积
- HDU 2577 How to Type DP .
- 为什么Java有GC还需要自己来关闭某些资源?
- iOS指纹解锁
- UltraEdit使用技巧
- hdu 4111 Alice and Bob(中档博弈题)★ ★
- 使用jQuery UI插件实现切换主题功能——经验小结
- 公司(企业与市场)与商业模式
- 20169月17-25日---身体,革命的本钱
- 细说 class类中的this指针与 构造函数