When the string length is 2: directly simulate (up to 26 times ).
When the string length is greater than 2:
1. Define the parity of a string as the parity of the sum of all characters of the string.
2. because the number of characters in the string is increased by 2 for each change
The answer must be n o.
3. When the parity of a string is the same, the answer must be yes;
It can be proved;
The following changes can be made to any three characters (x1, x2, X3:
(X1, x2, X3) → (x1, X3 + 1, X2 + 1) → (X2 + 2, X3 + 1, X1 + 1) → (X2 +
2, X1 + 2, X3 + 2) → (X1 + 3, X2 + 3, X3 + 2). (recorded as change mode 1 ).
On the basis of the Change Mode 1, the characters at the three positions are exchanged for 12 times each, that is
(X1 + 3 + 12 + 12, X2 + 3 + 12 + 12, X3 + 2 + 12 + 12) (X1 + 27, X2 +
27, X3 + 26) (marked as Change Mode 2 ).
In addition, there are a total of 26 small writing mothers, and the variant formula 2 is the same as (x1, x2, X3) →
(X1 + 1, X2 + 1, X3 ). That is to say, if the character position order is not changed
Characters.
Therefore, each time we only need to select characters at different positions than S2.
In method 2, either S1 is completely changed to S2, or S1 and S2 are only one bit
If only one character is set to different positions
The parity is the same, so the Change 1 operation can be performed so that the difference between the positions is evenly spread to another
Two locations, and then the other two locations are changed by the 2 operation to get the S2
# Include "stdio. H"
# Include "string. H"
Char A [100], B [100], c, d;
Int main ()
{
Int m, n, I, J, K, H, r = 1 ;;
Scanf ("% d", & K );
While (k --)
{
Scanf ("% S % s", a, B );
Int Len = strlen ();
Printf ("case # % d:", r ++ );
If (LEN = 2)
{
H = 0;
For (I = 0; I <26; I ++)
{
C = A [0];
A [0] = A [1] + 1;
If (A [0]> 'Z ')
A [0] = 'a ';
A [1] = C + 1;
If (A [1]> 'Z ')
A [1] = 'a ';
If (strcmp (a, B) = 0)
{
H = 1;
Break;
}
}
If (H = 1)
Printf ("Yes \ n ");
Else
Printf ("NO \ n ");
}
Else
{
M = n = 0;
For (I = 0; I <Len; I ++)
{
M + = A [I]-'A ';
N + = B [I]-'A ';
}
If (M> = N)
M = m-N;
Else
M = N-m;
If (M % 2)
Printf ("NO \ n ");
Else
Printf ("Yes \ n ");
}
}
Return 0;
}