大数乘,果断java A了。
import java.util.Scanner;
import java.lang.StringBuilder;
import java.math.BigInteger; public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while (cin.hasNextLine()) {
String line = cin.nextLine();
int length = line.length();
int[] cnt = new int[10];
for (int i=0; i<length; ++i) {
++cnt[line.charAt(i)-'0'];
}
boolean flag = true;
BigInteger org = new BigInteger(line);
for (int i=2; i<=length; ++i) {
BigInteger tmp = org.multiply(new BigInteger(String.valueOf(i)));
String s = tmp.toString();
int[] scnt = new int[10];
if (s.length() < length)
scnt[0] += length - s.length();
for (int j=0; j<s.length(); ++j)
++scnt[s.charAt(j)-'0'];
for (int j=0; j<10; ++j) {
if (scnt[j] != cnt[j]) {
flag = false;
break;
}
}
if (!flag)
break;
}
if (flag)
System.out.println(line+" is cyclic");
else
System.out.println(line+" is not cyclic");
}
}
}