HDU 2895 贪心 还是 大水题

DESCRIPTION:大意是给你两个字符串。编辑距离只有add和delete会产生。所以。编辑距离最短一定是两个字符串的长度差。然后...呵呵呵呵.... 猜题意就可以了...但是...我觉得这个题很不专业...题面上给的是删除时不输出字符...raner...还是要输出...还有就是...如果恰好当前对应的两个位置刚好相同..还是要modify...逗我玩呢....

总而言之。。已无力吐槽...

附代码:

#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;

char s1[10010], s2[10010];

int main()
{
    while (scanf("%s%s", s1, s2) != EOF)
    {
        int len1 = strlen(s1);
        int len2 = strlen(s2);
        if (len1 < len2)
        {
            for (int i=0; i<len2 - len1; ++i)
            {
                cout << "a " << s2[i] << endl;
            }
            for (int i=len2-len1; i<len2; ++i)
            {
                cout << "m " << s2[i] << endl;
            }
        }
        else if (len1 == len2)
        {
            for (int i=0; i<len2; ++i)
            {
                cout << "m " << s2[i] << endl;
            }
        }
        else if (len1 > len2)
        {
           // for (int i=0; i<len1-len2; ++i)
            for (int i=len1-len)
            {
                cout << "d " << s1[i] << endl;
            }
            for (int i=0; i<len2; ++i)
            {
                cout << "m " << s2[i] << endl;
            }
        }
    }
    return 0;
}

你可能感兴趣的:(HDU)