If a number of K multiplied by the square after N, the end result is equal to the number of digits K, then call this number " N-automorphic number." For example 3, the end is just two 2 9, so 9 is a 3- Automorphic number.
This question will ask you to write a program to determine whether a given number on a N is N- number sober.
Input formats:
Input is given in the first row positive integer M ( ≤), then a line is given the M to be detected, a positive integer of not more than 1,000.
Output formats:
If it is to be detected for each of the digital N- outputs the row number Automorphic smallest N and N K 2 values, separated by a space; otherwise the output . Note topic guarantee 0.No
Sample input:
3
92 5 233
Sample output:
3 25392 1 25 No
#include <iostream> using namespace std; bool judgeEndWith(int num1,int num2){ while(num2!=0){ if(num2%10!=num1%10) return false; num2/=10; num1/=10; } return true; } void selfNum(int a){ for(int i=1;i<10;i++){ if(judgeEndWith(a*a*i,a)){ cout<<i<<" "<<a*a*i<<endl; return; } } cout<<"No"<<endl; } int main(){ int M;int a; cin>>M; while(M--){ cin>>a; selfNum(a); } system("pause"); return 0; }