fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Main
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. long N, sum, subsidiary = 0, quantity = 0;
  10. Scanner in = new Scanner(System.in);
  11. N = in.nextLong();
  12. while (N > 999999999) {
  13. sum = 0;
  14. subsidiary = N;
  15. while (subsidiary!=0) {
  16. sum += subsidiary%10;
  17. subsidiary /= 10;
  18. }
  19. N -= sum;
  20. quantity++;
  21. }
  22. if (N == 999999999) {
  23. N = 0;
  24. quantity += 25632473;
  25. }
  26. while (N > 0) {
  27. sum = 0;
  28. subsidiary = N;
  29. while (subsidiary != 0) {
  30. sum += subsidiary%10;
  31. subsidiary /= 10;
  32. }
  33. N -= sum;
  34. quantity++;
  35. }
  36. System.out.println(quantity);
  37. }
  38. }
Success #stdin #stdout 0.06s 2184192KB
stdin
55555
stdout
3000