HDU 2577 How to Type DP也可以模拟】的更多相关文章

http://acm.hdu.edu.cn/showproblem.php?pid=2577 大意: 大家都打过字吧,现在有个有趣的问题:给你一串字符串,有大写有小写,要求你按键次数最少来输出它,输出按键次数. 大写字母可以通过caps lock 也可以用shift得到,小写也是. 但是起始状态和最后caps lock都是不锁定的. 求最少的按键次数. 思路: 不用DP的方法: 当有连续的大写或者小写用caps lock 键,否则用shift. #include<cstdio> #includ…
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 a…
题意: 打字游戏,求所按的最少次数.给出一个串,其中有大小写,大写需要按下cap键切换到大写,或者在小写状态下按shift+键,这样算两次,打小写时则相反.注意:在打完所有字后,如果cap键是开着的,要关它,也就是要算多一次. 思路: DP,根据每个字符打完后cap键盘是开着的还是关着的,最后dp[最后一个字符][关着的]为答案.规模降低到1个字符,每次考虑增加一个字符,打这个字符有两种选择,从上一个字符打完后的cap键关/开的两种状态来按下此字符,按完此字符后考虑使cap键开着或者关掉. dp…
How to Type Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4616    Accepted Submission(s): 2084 Problem Description Pirates have finished developing the typing software. He called Cathy to tes…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2577 解题报告:有一个长度在100以内的字符串,并且这个字符串只有大写和小写字母组成,现在要把这些字符串用键盘输入到电脑中,一开始的时候大写锁定是关闭的,并且要求结束的时候也是关闭的,然后让你求输入这些字符串最少需要按多少次键盘(包括Cap Lock键和Shift键) 一个典型的dp题,定义一个一维数组就够了,然后dp[i]的含义的输入到第i个字符时需要按键的最少次数.然后递推公式如下: dp[i]…
How to Type Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4658    Accepted Submission(s): 2110 Problem Description Pirates have finished developing the typing software. He called Cathy to tes…
题意:给出一个字符串,有大写有小写,问最少的按键次数.然后打字的这个人有一个习惯,打完所有的字之后,指示灯要关闭. dp[i][j]表示打到第i个字母,j有0,1两个值表示指示灯开或者关的状态 然后就可以写出状态转移方程了,因为最后需要灯是灭的,所以最后在找最小值的时候,dp[len][1]需要加1 又一次看的题解===go--go #include<iostream> #include<cstdio> #include<cstring> #include<alg…
题目链接 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…
题目链接 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…
题目转自hdu 2577,题目传送门 题目大意: 现给你n个区分大小写的字符串,大小写可用Caps Lock和shift切换(学过计算机的都知道) 但是有一点需要注意(shift是切换,若现在是大写锁定,用shift可切换成小写) 解题思路: 这道题一开始拿的时候,就觉得是n2的dp 但是,转移方程一直没想出来(0.25h) 后来又仔细想想,发现是2n的dp 然后想了想,20min就切了 我们先将字符串做预处理,形成一个01字符串 像这个测试数据: HELlowORLd 可以转换成这样: 然后,…