fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. int n, k, q, m;
  10. double N;
  11. Scanner in = new Scanner(System.in);
  12.  
  13. n = in.nextInt();
  14. k = in.nextInt();
  15.  
  16. m = n/k;
  17. q = n%k;
  18. N = Math.pow((m+1),k-q) * Math.pow((m+2),q);
  19.  
  20. System.out.println(q + " " + m + " " + N);
  21. }
  22. public static long pow(long x, int n) {
  23. return (n == 0) ? 1 :
  24. (n % 2 == 0) ? pow(x*x, n/2) :
  25. pow(x, n-1)*x;
  26. }
  27. }
Success #stdin #stdout 0.06s 4386816KB
stdin
4 3
stdout
1 1 12.0