fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. long n = Integer.parseInt(reader.readLine());
  13. int y = 0;
  14. int count = 0;
  15. double yRestriction = Math.round(Math.pow(n, (double) (1.0/3)));
  16. //System.out.println(yRestriction);
  17.  
  18. if(n < 1 || n > Math.pow(n, 18)){
  19. count = 0;
  20. }
  21. else{
  22. while(y <= yRestriction){
  23.  
  24. double yResult = Math.pow(y, 3);
  25. //System.out.println(yResult);
  26. double result = n - yResult;
  27. if(Math.sqrt(result) == (int) Math.sqrt(result)){
  28. count++;
  29. }
  30.  
  31. y++;
  32. }
  33. }
  34.  
  35.  
  36. System.out.println(count);
  37.  
  38. /*long endTime = System.currentTimeMillis();
  39. long searchTime = endTime - start;
  40. System.out.println(searchTime);
  41. */
  42.  
  43. }
  44. }
Success #stdin #stdout 0.05s 4386816KB
stdin
89
stdout
2