Advertisement
Saleh127

UVA 11221

Dec 11th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. int main()
  5. {
  6. ios_base::sync_with_stdio(0);
  7. cin.tie(0);
  8. cout.tie(0);
  9.  
  10.  
  11. int t;
  12. string a;
  13. cin>>t;
  14.  
  15. getline(cin,a);
  16.  
  17. for(int cs=1; cs<=t; cs++)
  18. {
  19. string b="",c;
  20.  
  21. getline(cin,a);
  22.  
  23. for(ll i=0; i<a.size(); i++)
  24. {
  25. if(a[i]>='a' && a[i]<='z')
  26. {
  27. b+=a[i];
  28. }
  29. }
  30. c=b;
  31. reverse(c.begin(),c.end());
  32.  
  33. cout<<"Case #"<<cs<<":\n";
  34.  
  35. if(c!=b)
  36. {
  37. cout<<"No magic :("<<endl;
  38. }
  39. else
  40. {
  41. ll l=b.size();
  42. ll x=sqrt(l);
  43.  
  44. if((x*x)==l)
  45. {
  46. cout<<x<<endl;
  47. }
  48. else
  49. {
  50. cout<<"No magic :("<<endl;
  51. }
  52. }
  53. }
  54.  
  55.  
  56. return 0;
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement