import java.math.BigInteger;
import java.util.Scanner;
public class MYL {
private static String integer;
private static int[] lists;
private static int strLen;
public static void main(String[] args) {
System.out.println("Please input a number:");
integer = new Scanner(System.in).next();
strLen = integer.length();
lists = new int[integer.length()];
for(int i = 0; i < lists.length; i++){
lists[i] = Integer.parseInt(integer.charAt(i)+"");
}
if(chakeThisNnmber(integer,lists,strLen)){
System.out.println("YES");
}else {
System.out.println("FALSE");
}
}
private static boolean chakeThisNnmber(String number ,int [] lists,int n) {
BigInteger bnumber = new BigInteger(number);
BigInteger result;
boolean falg = false;
for(int i = 1; i <= n ; i++){
result = bnumber.multiply(new BigInteger(i+""));
//System.out.println("test:" + result);
int [] mlist = new int[n];
for (int i1 = 0; i1 < n ;i1 ++) {
mlist[i1] = Integer.parseInt(result.toString().charAt(i1)+"");
//System.out.println("i1 = "+i1);
//System.out.println("result = " + result.toString().charAt(i1));
//System.out.println("mlist is " + mlist[i1]);
}
// mlist lists
for(int i2 = 0; i2 < n; i2++){
StringBuilder str = new StringBuilder();
for(int i3 = i2; i3 < n; i3++){
str = str.append(lists[i3]);
}
//System.out.println("the str's length is: "+ str.length());
if(str.length() < n){
int newLength = n-str.length();
for(int i4 = 0; i4 < newLength; i4++){
str.append(lists[i4]);
}
}
//System.out.println("str is " + str +" " + "result is :" + result + " equals? :" + str.toString().equals(result.toString()));
if(str.toString().equals(result.toString())){
falg = true;
}
//System.out.println("new Str is : " + str );
//System.out.println("===");
}
}
if(falg){
return true;
}else {
return false;
}
}
}
网友评论