- 注意特判 0 1
- 分解因子 从9到2
1 import java.util.Scanner; 2 3 public class P1014 4 { 5 public static void main(String args[]) 6 { 7 try (Scanner cin = new Scanner(System.in)) 8 { 9 while (cin.hasNext()) 10 { 11 int n = cin.nextInt(); 12 StringBuilder builder = new StringBuilder(); 13 if (n == 0) 14 System.out.println(10); 15 else if (n == 1) 16 System.out.println(1); 17 else 18 { 19 for (int k = 9; k >= 2; k--) 20 while (n % k == 0) 21 { 22 n /= k; 23 builder.append(k); 24 } 25 if (n == 1) 26 System.out.println(builder.reverse()); 27 else 28 System.out.println(-1); 29 } 30 } 31 } 32 } 33 }
时间: 2024-10-28 14:38:09