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. Python 的经典入门书籍有哪些?

    是不是很多人跟你说,学Python开发就该老老实实地找书来看,再配合死命敲代码?电脑有了,软件也有了,心也收回来了?万事俱备,唯独只欠书籍?没找到到合适的书籍?可以看看这些. 1.Python基础教程 ...

  2. postman 第5节 Runner的使用(转)

    1.首先在postman新建要批量运行的接口文件夹,新建一个接口,并设置好全局变量. 2.然后在Test里面设置好要断言的方法 如: tests["Status code is 200&qu ...

  3. Nginx + Memcached 实现Session共享的负载均衡

    session共享 我们在做站点的试试,通常需要保存用户的一些基本信息,比如登录就会用到Session:当使用Nginx做负载均衡的时候,用户浏览站点的时候会被分配到不同的服务器上,此时如果登录后Se ...

  4. 我的Java起源

    2015年九月八号我和我爸一同去Java的培训学校,我是一名读了高一就不读的学生.抛弃高中就一个理由--不喜欢,是的,我不喜欢高中的课程.我不理解我一辈子不会出地球为什么我要学习那些内容,如果我就自己 ...

  5. Javascript的内容摘要

    JS简介和变量 {JS的三种方式}            1 HTML中内嵌JS(不提倡使用)            <button onclick="javascript:alert ...

  6. 这是一款借助chrome 插件的微信机器人

    1.chrome kit微信机器人简介 借助chrome 插件 js注入来实现消息的发送 chrome devtool api的调用来监听https请求 打开微信登录界面,在扫码登录前必须先打开too ...

  7. CloseableHttpClient 源码

    public abstract class CloseableHttpClient implements HttpClient, Closeable { private final Log log = ...

  8. 入门-什么是webshell?

    webshell是什么? 顾名思义,"web" - 显然需要服务器开放web服务,"shell" - 取得对服务器某种程度上操作权限. webshell常常被称 ...

  9. MPLS LDP随堂笔记2

    前一天排错 Acl 1 匹配所有ospf的数据包 (目的 ospf建立邻居关系 传递路由条目) 2 放行UDP报文 让LDP邻居能互相收发HELLO包 4 放行TCP报文 让LDP邻居能够建立TCP会 ...

  10. 201521123107 《Java程序设计》第1周学习总结

    第1周学习总结 1.本周学习总结 本周我们正式开始了对一门新的编程语言java的学习.本周的主要内容是初步了解了java的发展过程,java具有简约且简单 .平台无关性等优点.java的3个关键的工具 ...