Vimal has found two very old sheets of paper, each of which originally contained a string of lowercase Latin letters. The strings on both the sheets have equal lengths. However, since the sheets are very old, some letters have become unreadable.Vimal would like to estimate the difference between these strings. Let's assume that the first string is named S1, and the second S2. The unreadable symbols are specified with the question mark symbol '?'. The difference between the strings equals to the number of positions i, such that S1i is not equal to S2i, where S1i and S2i denote the symbol at the i the position in S1 and S2, respectively.Vimal would like to know the minimal and the maximal difference between the two strings, if he changes all unreadable symbols to lowercase Latin letters. Now that you're fully aware of Vimal's programming expertise, you might have guessed that he needs you help solving this problem as well. Go on, help him!

#include<stdio.h>

int main()

{

int t,minimal,maximal,count,i;

char S1[101],S2[101];

scanf("%d",&t);

while(t--)

{scanf("%s %s",S1,S2);

i=0;

count=minimal=maximal=0;

while(S1[i]!='\0')

{if(S1[i]=='?'||S2[i]=='?')

count++;

else if(S1[i]!=S2[i])

minimal++;

 

i++;

}

maximal=minimal+count;

printf("%d %d\n",minimal,maximal);

}

return 0;

Comments

Popular posts from this blog

Elavenil has a chessboard with N rows and M columns. In one step, he can choose two cells of the chessboard which share a common edge (that has not been cut yet) and cut this edge. Formally, the chessboard is split into two or more pieces if it is possible to partition its cells into two non-empty subsets S1 and S2 (S1∩S2=∅, |S1|+|S2|=NM) such that there is no pair of cells c1,c2 (c1∈S1,c2∈S2) which share a common edge that has not been cut.Elavenil does not want the board to split into two or more pieces. Compute the maximum number of steps he can perform while satisfying this condition.

The Matriculation school have arranged an Annual Day Function.Volunteers have decorated a floor on various places of the school using Rose and Tulip flowers. But one of the coordinators requested the volunteers to rearrange the decoration like a triangular size.Coordinator also told them that tulips flowers need to be positioned at the middle of the roses

Mukesh and Salima was looking to buy Organic Apples in the nearest fruits shop.But Shop Owner mixed the Hybrid apples in that Apple box. After sometimes Mukesh checking the box, he was confused among organic and hybrid apple. He started to count the hybrid apples. Please help to Mukesh Count the total number of hybrid apples in the box.