How to Type

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3435    Accepted Submission(s): 1595

Problem Description
Pirates have finished developing the typing software. He called Cathy to test his typing software. She is good at thinking. After testing for several days, she finds that if she types a string by some ways, she will type the key at least. But she has a bad habit that if the caps lock is on, she must turn off it, after she finishes typing. Now she wants to know the smallest times of typing the key to finish typing a string.
 
Input
The first line is an integer t (t<=100), which is the number of test case in the input file. For each test case, there is only one string which consists of lowercase letter and upper case letter. The length of the string is at most 100.
 
Output
For each test case, you must output the smallest times of typing the key to finish typing this string.
 
Sample Input
3
Pirates
HDUacm
HDUACM
 
Sample Output
8 8 8
 #include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
void fun(char a[])
{
int b[][];
memset(b,,sizeof(b));
b[][]=;
int i,j,len=strlen(a);
for(i=;i<=len;i++)
{
if(a[i-]<='z'&&a[i-]>='a')
{
b[i][]=min(b[i-][]+,b[i-][]+);
b[i][]=min(b[i-][]+,b[i-][]+);
}
else
{
b[i][]=min(b[i-][]+,b[i-][]+);
b[i][]=min(b[i-][]+,b[i-][]+);
}
}
cout<<min(b[len][],b[len][]+)<<endl;
}
int main()
{
int t;
cin>>t;
char a[];
while(t--)
{
cin>>a;
fun(a);
}
}

hud 2577 How to Type的更多相关文章

  1. HDU 2577 How to Type (线性dp)

    How to Type Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  2. HDU 2577 How to Type(dp题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2577 解题报告:有一个长度在100以内的字符串,并且这个字符串只有大写和小写字母组成,现在要把这些字符 ...

  3. 【HDOJ】2577 How to Type

    DP. /* 2577 */ #include <cstdio> #include <cstring> #include <cstdlib> #define MAX ...

  4. hdu 2577 How to Type(dp)

    Problem Description Pirates have finished developing the typing software. He called Cathy to test hi ...

  5. HDU 2577 How to Type (字符串处理)

    题目链接 Problem Description Pirates have finished developing the typing software. He called Cathy to te ...

  6. HDU 2577 How to Type (字符串处理)

    题目链接 Problem Description Pirates have finished developing the typing software. He called Cathy to te ...

  7. HDU 2577 How to Type DP也可以模拟

    http://acm.hdu.edu.cn/showproblem.php?pid=2577 大意: 大家都打过字吧,现在有个有趣的问题:给你一串字符串,有大写有小写,要求你按键次数最少来输出它,输出 ...

  8. hdu 2577 How to Type(DP)

    How to Type Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  9. HDU 2577 How to Type【DP】

    题意:给出一个字符串,有大写有小写,问最少的按键次数.然后打字的这个人有一个习惯,打完所有的字之后,指示灯要关闭. dp[i][j]表示打到第i个字母,j有0,1两个值表示指示灯开或者关的状态 然后就 ...

随机推荐

  1. Winform 下载服务器安装包并安装

    代码中包含了检测本地安装盘符代码 一,定义下载委托事件(用于实现前台进度条更新和下载完成后事件的回调): private delegate void Action(); private string ...

  2. Centos 6系统修复grub

    author:JevonWei 版权声明:原创作品 错误界面如下时,应该是grub的stage数据有缺失,应该从新安装grub GRUB引导的stage1阶段损坏,系统启动会直接进入光盘引导界面,st ...

  3. flex弹性布局学习

    一.介绍 flex( flexible box:弹性布局盒模型),是2009年w3c提出的一种可以简洁.快速弹性布局的属性.主要思想是给予容器控制内部元素高度和宽度的能力.目前已得到以下浏览器支持: ...

  4. JavaWeb程序连接SQLserver数据库

    声明:一直以来都以为javaweb程序连接数据库是一个很高大上很难的问题,结果今天学习了一下,不到两个小时就解决了,所以总结一篇博客. JavaWeb程序连接SQLserver数据库分为一下步骤: 1 ...

  5. Java缓存类的实际应用场景

    不要着迷于技术,应把注意力放到问题上. 一个普通的后台管理系统,一定会有参数配置.参数配置数据表和其他的数据表是不同的,它的操作基本都是查的操作.参数配置的这些数据信息是贯穿在整个项目中,那么把他们放 ...

  6. Nginx做文件下载服务器

    这是最简单的一种办法,贴完代码就能用 server { listen 80; charset utf-8; server_name localhost; root /data/file/; autoi ...

  7. 第二次项目冲刺(Beta阶段)5.23

    1.提供当天站立式会议照片一张 会议内容: ①检查前一天的任务情况,将遇到的瓶颈反馈,看看团队成员是否有好的建议. ②制定新一轮的任务计划. 2.每个人的工作 (1)工作安排 队员 今日进展 明日安排 ...

  8. 结对实验---基于GUI的四则运算

    详细代码:https://git.coding.net/wangluo24/NO.2.git 结对伙伴:吕志哲(201421123021) &本人.许明涛 201421123024 一.题目要 ...

  9. IT之光

    作为一个IT界的新新人才,现在拥有第一个博客,可以在这里学习和分享IT方面的知识和技术.

  10. 201521123111《Java程序设计》第7周学习总结

    1. 本章学习总结 以你喜欢的方式(思维导图或其他)归纳总结集合相关内容. 线性表,栈,队列,哈希表是常用的数据结构 在java.util包中有这些数据结构的实现类.比如:List接口,实现类Arra ...