Question description
This question is a fill-in-the-blank question. You only need to calculate the result and use the output statement in the code to output the filled-in result.
Many 10-digit numbers can be formed from the 10 numbers from 0 to 9 without repetition or omission. There are also many of them that happen to be square numbers (the square of a number).
For example: 1026753849 is the smallest square number among them.
Please find out what is the largest square number among them?
operating restrictions
- Maximum running time: 1s
- Maximum running memory: 128M
import java.util.*;
public class Main {
public static void main(String[] args) {
for(long i=100000;i>6666;i--){
if(check(i*i)==1){
System.out.println(i*i);
break;
}
}
}
public static int check(long n){
int flag=1;
int k=0;
int[] f=new int[10];
while(n>0){
k=(int)(n%10);
f[k]++;
n=n/10;
if (f[k] > 1) {
flag = 0;
break;
}
}
return flag;
}
}