#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
int t, j = 1, i;
cin >> t;
getchar();
while(t--)
{
getline(cin, s);
string st;
for(i=0;i<s.size();i++)
{
if(s[i] >= 'a' && s[i] <= 'z')
st.push_back(s[i]);
}
int n = st.size();
int l = sqrt(n);
cout << "Case #" << j++ << ":\n";
if(l*l == n)
{
string ch = st;
reverse(ch.begin(), ch.end());
int f = 1;
for(i=0;i<n;i++)
{
if(st[i] != ch[i])
{
f = 0;
break;
}
}
if(f == 1)
{
cout << l << "\n";
}
else
{
cout << "No magic :(" << "\n";
}
}
else
{
cout << "No magic :(" << "\n";
}
}
return 0;
}
using namespace std;
int main()
{
string s;
int t, j = 1, i;
cin >> t;
getchar();
while(t--)
{
getline(cin, s);
string st;
for(i=0;i<s.size();i++)
{
if(s[i] >= 'a' && s[i] <= 'z')
st.push_back(s[i]);
}
int n = st.size();
int l = sqrt(n);
cout << "Case #" << j++ << ":\n";
if(l*l == n)
{
string ch = st;
reverse(ch.begin(), ch.end());
int f = 1;
for(i=0;i<n;i++)
{
if(st[i] != ch[i])
{
f = 0;
break;
}
}
if(f == 1)
{
cout << l << "\n";
}
else
{
cout << "No magic :(" << "\n";
}
}
else
{
cout << "No magic :(" << "\n";
}
}
return 0;
}
Comments
Post a Comment