hdu2577 how to type
来源:互联网 发布:mac版解压软件下载 编辑:程序博客网 时间:2024/04/29 13:55
//dp[i][0] 表示type i 时cap处于关的状态//dp[i][1] 表示开的状态。//注意,初始化的时候要将dp[0][1]=1其他为0//因为开始的时候cap是关的#include <cstdio>#include <cstring>#include <string>#include <algorithm>using namespace std;const int maxn = 108;int dp[maxn][2];char a[maxn];int n;void init(){scanf("%s",a);n = strlen(a);memset(dp,0,sizeof(dp));dp[0][1]=1;}void solve(){for (int i=0;i<n;i++){if (a[i]>='a'&&a[i]<='z'){dp[i+1][0] = min(dp[i][0]+1,dp[i][1]+2);dp[i+1][1] = min(dp[i][0]+2,dp[i][1]+2);}else {dp[i+1][0] = min(dp[i][0]+2,dp[i][1]+2);dp[i+1][1] = min(dp[i][0]+2,dp[i][1]+1);}}}void print(){printf("%d\n",min(dp[n][0],dp[n][1]+1));}int main(){int t; freopen("G:\\Code\\1.txt","r",stdin);scanf("%d",&t);while(t--){init();solve();print();}}
0 0
- HDU2577 How to Type
- HDU2577--How to Type
- hdu2577 How to Type
- HDU2577--How to Type
- hdu2577 how to type
- HDU2577 How to Type
- HDU2577 How to Type
- HDU2577 How to Type
- HDU2577 How to Type
- HDU2577:How to Type(DP)
- HDU2577 How to Type【DP】
- HDU2577 How to Type (DP)
- hdu2577 How to Type---DP
- hdu2577 特殊动归 How to Type
- hdu2577——How to Type
- hdu2577 How to Type(经典DP)
- hdu2577 How to Type(DP)
- HDU2577 How to Type (动态规划)
- 安防
- 数据挖掘
- Storm On Yarn部署
- js画图开发库--mxgraph--[perimeter-边界.html ]
- lua中栈的详细流程
- hdu2577 how to type
- ora 12514 tns监听程序当前无法识别
- No resource found that matches the given name 'Theme.AppCompat.Light 的完美解决方案
- android API Guides 之 web app -------------Overview
- 黑马程序员---【C语言】01漫谈C与C++
- linux crond 脚本.sh
- 大陆身份证号码正则验证js脚本
- IOS程序启动原理(启动过程)、UIApplication(main.m与自动生成的AppDelegate代理)
- xxxHive-1-安装配置