您的位置:首页 > 其它

ZCMU—1425

2016-12-09 10:38 197 查看

1425: Careless Tony

Time Limit: 1 Sec  Memory Limit: 128 MB

Submit: 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 then
type 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

2
1
WishingBone
WashingBone
1
Oops
Oooops

Sample Output

20
6

【分析】

没啥难度....主要是读题目吧...不要被英文题忽悠了..其实就是只要从头扫一遍,找到第一个不一样的位置然后计算删过去再打回来的时间就好了...
【代码】
#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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: