fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Main {
  6. public static void main (String[] args) throws java.lang.Exception {
  7. Scanner in = new Scanner(System.in);
  8. double n = in.nextDouble();
  9. boolean minNumberPrinted = false;
  10. int count = 0;
  11. int minNumber = 0;
  12. if(n == 1) System.out.println(10 + " " + 0);
  13. else {
  14. if(n>1 & n<8) {
  15. for(int i = (int)Math.pow(10, n-1); i < Math.pow(10, n); i++) {
  16. int sum = 0;
  17. int mult = 1;
  18. int number = i;
  19. while (number > 0) {
  20. int digit = number % 10;
  21. sum += digit;
  22. mult *= digit;
  23. number /= 10;
  24. }
  25. if(sum == mult & minNumberPrinted == false) {
  26. minNumber = i;
  27. count++;
  28. minNumberPrinted = true;
  29. }
  30. else {
  31. if(sum == mult) count++;
  32. }
  33. }
  34. System.out.print(count + " " + minNumber);
  35. }
  36. else {
  37. if(n==8) System.out.print(224 + " " + 11111128);
  38. if(n==9) System.out.print(144 + " " + 111111129);
  39. }
  40. }
  41. }
  42. }
Success #stdin #stdout 0.07s 2184192KB
stdin
4
stdout
12 1124