Codeforces Round #104 (Div. 1)
A. Lucky Conversion
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 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya has two strings a and b of the same length n. The strings consist only of lucky digits. Petya can perform operationsof two types:
- replace any one digit from string a by its opposite (i.e., replace 4 by 7 and 7 by 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.
solution:
As i have solve this problem in a very easy way...just check it out....
#include<iostream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<queue>
#include<list>
#define show(x) copy(x.begin(),x.end(),output)
#include<iterator>
#define sort(x) sort(x.begin(),x.end())
#include<string>
#define vs vector<string>
#define vi vector<int>
#define pb push_back
#include<map>
#include<algorithm>
#include<sstream>
#include<stack>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<cctype>
using namespace std;
using namespace std;
int main()
{
string s , s1;
int count1 = 0 , count2 = 0;
cin>>s>>s1;
for(int i = 0 ; i <s.size(); i++)
{
if(s[i] != s1[i])
{
if(s[i] == '4')
count1++;
else
count2++;
}
}
if(count1 <= count2)
cout<<count2;
else
cout<<count1;
cin.get();
return 0;
}
BY: SAURABH BHATIA(GNDU , RC JAL)
No comments:
Post a Comment