ZCMU—1425
2016-12-09 10:38
197 查看
1425: Careless Tony
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 89 Solved: 26
[Submit][Status][Web
Board]
Description
Tony is such a careless typist that he finds himself making mistakes AGAIN. What's worse, the cursor key is not working so that he can only use the backspace key to reach the place where the mistake is, and thentype whatever he's deleted on the way AGAIN :(
Now let's help Tony find out at least how long it will cost him to correct his mistake.
Input
The first line of input contains an integer N, which is the number of test cases. Then N test cases follow.Each test case consists of 3 lines of input:
the 1st line contains a positive integer t (<= 100), which is the time taken for Tony to delete/input a character;
the 2nd line contains the correct content of text;
and the 3rd line contains the text typed by Tony.
Note: The text contents contain only the readable characters. The total length of each text is no longer than 80 characters.
Output
For each test case, print in one line the minimal time taken for Tony to correct his mistake.Sample Input
21
WishingBone
WashingBone
1
Oops
Oooops
Sample Output
206
【分析】
没啥难度....主要是读题目吧...不要被英文题忽悠了..其实就是只要从头扫一遍,找到第一个不一样的位置然后计算删过去再打回来的时间就好了...【代码】
#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; int main() { int pp;scanf("%d",&pp); while(pp--) { int time; char s[200],ss[200]; scanf("%d",&time); scanf("%s%s",s,ss); int len1=strlen(s); int len2=strlen(ss); int i=0; for(;i<min(len1,len2);i++) if(s[i]!=ss[i]) break; printf("%d\n",time*(len1+len2-2*i)); } return 0; }
相关文章推荐
- ZCMU-1425-Careless Tony
- hdu 1425 简单的数的hash
- UltraEdit – 应用程序错误: 未知的软件异常 (0xc0000417),位置为 0x00ae1425 解决方案
- UESTC1425-LCIS 线段树区间合并
- UESTC1425 - Another LCIS(成段更新&&区间合并)
- hdu 1425 sort
- CSU 1425 NUDT校赛 I题 Prime Summation
- hdu 1425 sort (水题,计数法)
- 杭电1425
- 1425 sort
- zcmu1540 第k大数
- HDOJ_1425  sort 桶排序
- hdu 1425 sort
- zcmu 1617补提交
- ZCMU—1231
- ZCMU—1689
- ZCMU—1129
- ZCMU—1778
- ZCMU—1602
- ZCMU-1151-搭数字2