博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hud 2577 How to Type
阅读量:5982 次
发布时间:2019-06-20

本文共 1742 字,大约阅读时间需要 5 分钟。

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

 

 

 

1 #include 
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 using namespace std; 9 void fun(char a[])10 {11 int b[200][2];12 memset(b,0,sizeof(b));13 b[0][1]=1;14 int i,j,len=strlen(a);15 for(i=1;i<=len;i++)16 {17 if(a[i-1]<='z'&&a[i-1]>='a')18 {19 b[i][0]=min(b[i-1][0]+1,b[i-1][1]+2);20 b[i][1]=min(b[i-1][0]+2,b[i-1][1]+2);21 }22 else23 {24 b[i][1]=min(b[i-1][0]+2,b[i-1][1]+1);25 b[i][0]=min(b[i-1][0]+2,b[i-1][1]+2);26 }27 }28 cout<
<
>t;34 char a[200];35 while(t--)36 {37 cin>>a;38 fun(a);39 }40 }
View Code

 

转载于:https://www.cnblogs.com/ERKE/p/3826873.html

你可能感兴趣的文章
Linux备份ifcfg-eth0文件导致的网络故障问题
查看>>
2018年尾总结——稳中成长
查看>>
通过jsp请求Servlet来操作HBASE
查看>>
Shell编程基础
查看>>
Shell之Sed常用用法
查看>>
Centos下基于Hadoop安装Spark(分布式)
查看>>
mysql开启binlog
查看>>
设置Eclipse编码方式
查看>>
分布式系统唯一ID生成方案汇总【转】
查看>>
并查集hdu1232
查看>>
Mysql 监视工具
查看>>
Linux Namespace系列(09):利用Namespace创建一个简单可用的容器
查看>>
博客搬家了
查看>>
Python中使用ElementTree解析xml
查看>>
linux的日志服务器关于屏蔽一些关键字的方法
查看>>
mysql多实例实例化数据库
查看>>
javascript 操作DOM元素样式
查看>>
HBase 笔记3
查看>>
【Linux】Linux 在线安装yum
查看>>
Atom 编辑器系列视频课程
查看>>