public class Solution {
static long[][] sumArray = getSumNumberArray();
public static long[] getNumbers(long N){
long[] result = null;
ArrayList<Long> numArmst = new ArrayList<Long>();
for (long i=120;i<N+1;i++){
if (i<10){numArmst.add(i);}
if (i>9&&i<100){
long a = i/10;
long b = i-(i/10)*10;
if (a<=b){
if ((a*a+b*b)==i){numArmst.add(i);}
}
}
if(i>99){
String number = Long.toString(i);
char[] arrNum = number.toCharArray();
int a = Integer.parseInt(arrNum[0]+"");
int b = Integer.parseInt(arrNum[1]+"");
int c = Integer.parseInt(arrNum[2]+"");
System.out.println(Arrays.toString(arrNum)+" "+a+" "+b+" "+c);
if (a<=b&&b<=c){
long sum=0;
int M = (int) Math.ceil(Math.log10(i + 0.5));
for(char ch:arrNum){
sum+=getSum(Integer.parseInt(ch+""),M);
}
System.out.println(" M="+M+" i="+i+" sum="+sum);
if (i==sum){numArmst.add(i);System.out.println("ok");}
}
}
}
if (numArmst.size()==0){
result = new long[1];
result[0]=0;
return result;}
else {
result = new long[numArmst.size()];
for (int i=0;i<numArmst.size();i++){
result[i]=numArmst.get(i);
}
return result;}
}
public static long getSum(int num, int stepen){
long sum = sumArray[num][stepen-1];
return sum;
}
public static long[][] getSumNumberArray(){
long[][] arr = new long[10][19];
int a = 0;
for(int b=1;b<20;a++){
//System.out.print("a="+a+" b="+b);
if (a==10){a=-1;b++;}
else{arr[a][b-1]=(long)Math.pow(a, b);
//System.out.println(" "+arr[a][b-1]);
}
}
return arr;
}
public static void main(String[] args) {
long[] arrArmstrong = getNumbers(160);
System.out.println(Arrays.toString(arrArmstrong));
}
}