#include <iostream>
using namespace std;
// Function to check Automorphic number
bool isAutomorphic(int N)
{
if(N < 0) N = -N;
// Store the square
int sq = N * N;
// Start Comparing digits
while (N > 0) {
// Return false, if any digit of N doesn't
// match with its square's digits from last
if (N % 10 != sq % 10)
return false;
// Reduce N and square
N /= 10;
sq /= 10;
}
return true;
}
// Driver code
int main()
{
int N = 5;
isAutomorphic(N) ? cout << "Automorphic"
: cout << "Not Automorphic";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKLy8gRnVuY3Rpb24gdG8gY2hlY2sgQXV0b21vcnBoaWMgbnVtYmVyCmJvb2wgaXNBdXRvbW9ycGhpYyhpbnQgTikKewoJCglpZihOIDwgMCkgTiA9IC1OOwoJCgoJLy8gU3RvcmUgdGhlIHNxdWFyZQoJaW50IHNxID0gTiAqIE47CgoJLy8gU3RhcnQgQ29tcGFyaW5nIGRpZ2l0cwoJd2hpbGUgKE4gPiAwKSB7CgkJLy8gUmV0dXJuIGZhbHNlLCBpZiBhbnkgZGlnaXQgb2YgTiBkb2Vzbid0CgkJLy8gbWF0Y2ggd2l0aCBpdHMgc3F1YXJlJ3MgZGlnaXRzIGZyb20gbGFzdAoJCWlmIChOICUgMTAgIT0gc3EgJSAxMCkKCQkJcmV0dXJuIGZhbHNlOwoKCQkvLyBSZWR1Y2UgTiBhbmQgc3F1YXJlCgkJTiAvPSAxMDsKCQlzcSAvPSAxMDsKCX0KCglyZXR1cm4gdHJ1ZTsKfQoKLy8gRHJpdmVyIGNvZGUKaW50IG1haW4oKQp7CglpbnQgTiA9IDU7CgoJaXNBdXRvbW9ycGhpYyhOKSA/IGNvdXQgPDwgIkF1dG9tb3JwaGljIgoJCQkJCTogY291dCA8PCAiTm90IEF1dG9tb3JwaGljIjsKCglyZXR1cm4gMDsKfQo=