Time limit: Ms | Memory Limit: 65535 KB
Difficulty: 1
Describe
The King has a magic mirror that can turn anything that touches the mirror twice times the original-just because it is a mirror, the added part is reversed.
Like a necklace, we use AB to indicate that different letters represent different colors of pearls. If the B end touches the mirror, the mirror will turn this necklace into ABBA. If the other end touches, it becomes abbaabba (assuming the king only touches the mirror with one end of the necklace).
Given the final necklace, write the program output the minimum length that the original necklace may be before the king does not use the magic mirror.
Input
The first line is an integer N (n<=10) that represents the number of groups of test data)
Each group of test data occupies only one string (less than 100), consisting of uppercase English letters that represent the final necklace.
Output
The output of each set of test data has only one integer, indicating the smallest possible length of the original necklace before the king used the Magic mirror.
Sample input
2
Abbaabba
A
Sample output
2
1
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace Std;
int main ()
{
int A;
cin>>a;
while (a--)
{
Char str[105];
int Len;
cin>>str;
Len=strlen (str);
while (len%2==0)
{
if (STR[LEN/2-1]==STR[LEN/2])
{
len/=2;
}
Else
Break
}
cout<<len<<endl;
}
return 0;
}
The Magic mirror of the King