TJU : 1856 (Anagrammatic Distance)



// http://acm.tju.edu.cn/toj/showp1856.html
// Tag: Adhoc

#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

int main ()
{
    int testCase; scanf ("%d", &testCase);
    int cases = 0;
    getchar ();
    int freq [26 + 3];

    while ( testCase-- ) {
        char a [100], b [100];
        gets (a);
        gets (b);

        memset (freq, 0, sizeof freq);

        for ( int i = 0; a [i]; i++ ) freq [a [i] - 'a']++;
        for ( int i = 0; b [i]; i++ ) freq [b [i] - 'a']--;

        int cnt = 0;
        for ( int i = 0; i < 26; i++ ) cnt += abs (freq [i]);

        printf ("Case #%d:  %d\n", ++cases, cnt);
    }

    return 0;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s