Codeforces 145A Lucky Conversion(思维)

来源:互联网 发布:ibm linux 编辑:程序博客网 时间:2024/06/04 23:34

Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 477444 are lucky and 517467 are not.

Petya has two strings a and b of the same length n. The strings consist only of lucky digits. Petya can perform operations of two types:

  • replace any one digit from string a by its opposite (i.e., replace 4 by 7 and 7by 4);
  • swap any pair of digits in string a.

Petya is interested in the minimum number of operations that are needed to make string a equal to string b. Help him with the task.

Input

The first and the second line contains strings a and b, correspondingly. Strings aand b have equal lengths and contain only lucky digits. The strings are not empty, their length does not exceed 105.

Output

Print on the single line the single number — the minimum number of operations needed to convert string a into string b.

Example
Input
4774
Output
1
Input
774744
Output
1
Input
777444
Output
3
Note

In the first sample it is enough simply to swap the first and the second digit.

In the second sample we should replace the second digit with its opposite.

In the third number we should replace all three digits with their opposites.



题解:

直接扫两个串记录不同时候的4和7的个数,取最大值

代码:

#include<stdio.h>#include<string.h>#include<stdlib.h>#include<queue>#include<stack>#include<math.h>#include<vector>#include<map>#include<set>#include<stdlib.h>#include<cmath>#include<string>#include<algorithm>#include<iostream>#include<stdio.h>using namespace std;#define ll long longint main(){    char s1[100005],s2[100005];    int i,j,d1=0,d2=0;    scanf("%s%s",s1,s2);    for(i=0;s1[i];i++)    {        if(s1[i]!=s2[i])        {            if(s1[i]=='7')                d1++;            else                d2++;        }    }    printf("%d\n",max(d1,d2));    return 0;}