HDU 2577 How to Type (DP,经典)】的更多相关文章

题意: 打字游戏,求所按的最少次数.给出一个串,其中有大小写,大写需要按下cap键切换到大写,或者在小写状态下按shift+键,这样算两次,打小写时则相反.注意:在打完所有字后,如果cap键是开着的,要关它,也就是要算多一次. 思路: DP,根据每个字符打完后cap键盘是开着的还是关着的,最后dp[最后一个字符][关着的]为答案.规模降低到1个字符,每次考虑增加一个字符,打这个字符有两种选择,从上一个字符打完后的cap键关/开的两种状态来按下此字符,按完此字符后考虑使cap键开着或者关掉. 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…
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…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2993 题目大意:给出n,k,给定一个长度为n的序列,从其中找连续的长度大于等于k的子序列使得子序列中的平均值最小. 解题思路:斜率DP经典题, 详细分析见: NOI2004年周源的论文<浅谈数形结合思想在信息学竞赛中的应用> 还有要注意要用输入输出外挂,不是getchar()版的,是fread()版的,第一次遇到这么变态的题目- -|||. 代码: #include<iostream>…