Source code for submission s893

Lotion.java

  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package senseofsecuritz;
  6.  
  7. import java.io.BufferedReader;
  8. import java.io.InputStreamReader;
  9.  
  10. /**
  11.  *
  12.  * @author istenik3
  13.  */
  14. public class Lotion {
  15. static public void main(String [] arguments) throws Exception {
  16.  
  17. String line;
  18. while((line = reader.readLine()) != null) {
  19. int n = Integer.parseInt(line.substring(2));
  20.  
  21. System.out.println(solve(n));
  22. }
  23. }
  24.  
  25. static public int solve(long n) {
  26. int pocet = 0;
  27. for(long x=(n+1); x<=2*n; x++) {
  28. long y=(x*n)/(x-n);
  29. if(right(x, y, n)) {
  30. pocet++;
  31. }
  32. }
  33. return pocet;
  34. }
  35.  
  36. static public boolean right(long x, long y, long n) {
  37. return ((x*y) / (x+y)) == n;
  38. }
  39. }
  40.