【DP】HDU 2577 How to Type
来源:互联网 发布:网络骚扰电话打不停 编辑:程序博客网 时间:2024/05/21 13:59
题意:求最少按键盘多少次
注意当大写开关开着时按shift打出来的是小写
dp[i][j] i==0表示没开大写 i==1 表示开大写;
#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>#include <string>#include <iostream>#include <algorithm>using namespace std;#include <queue>#include <stack>#include <vector>#include <deque>#include <set>#include <map>#define IN freopen ("in.txt" , "r" , stdin);#define OUT freopen ("out.txt" , "w" , stdout);typedef long long LL;const int MAXN = 111;//点数的最大值const int MAXM = 20006;//边数的最大值const int INF = 11521204;const int mod=1000000007;int dp[2][122];bool daxie(char c){ if(c>='A'&&c<='Z') return true; else return false;}int main(){ int t; char s[111]; scanf("%d",&t); while(t--) { scanf("%s",&s); int len=strlen(s); dp[0][0]=0,dp[1][0]=INF; for(int i=1;i<=len;i++) if(daxie(s[i-1]))//大写的情况 { dp[0][i]=min(dp[0][i-1]+2,dp[1][i-1]+2); dp[1][i]=min(dp[0][i-1]+2,dp[1][i-1]+1); } else//小写 { dp[0][i]=min(dp[0][i-1]+1,dp[1][i-1]+2); dp[1][i]=min(dp[0][i-1]+2,dp[1][i-1]+2); } printf("%d\n",dp[0][len]); } 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)
- 编程:休息片刻的好处
- android,system.img 打包
- hash算法比较
- 每天一个linux命令:touch 命令
- SELECT INTO 和 INSERT INTO SELECT 两种表复制语句
- 【DP】HDU 2577 How to Type
- 11个提问频率最高的PHP面试题
- Eclipse Debug不为人知的秘密
- ABA问题
- [unix]Vim初始化
- Spring之依赖
- linux下pptpd服务器配置
- 64位系统注册32位的directshow filter文件
- 联合概率分布函数的问题