Source code for submission s711

Go to diff to previous submission

Main.java

  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package fl;
  6.  
  7. import java.io.BufferedReader;
  8. import java.io.InputStreamReader;
  9. import java.util.Scanner;
  10.  
  11. /**
  12.  *
  13.  * @author kuric10
  14.  */
  15. public class Main {
  16.  
  17. /**
  18.   * @param args the command line arguments
  19.   */
  20. public static void main(String[] args) {
  21. // TODO code application logic here
  22. /* BufferedReader input= new BufferedReader(new InputStreamReader(System.in));
  23.   String s;*/
  24.  
  25. Scanner input= new Scanner(System.in);
  26. int citatel, menovatel;
  27. int max;
  28. int counter;
  29. double tolerancia=0.00000001;
  30. double pom;
  31. String s;
  32.  
  33. while(input.hasNextLine()){
  34. counter=0;
  35. s=input.nextLine();
  36.  
  37. //citatel=input.nextInt();
  38. menovatel=Integer.parseInt(s.substring(2)); //input.nextInt();
  39. max=menovatel*3;
  40. /* for (int i = menovatel; i < max; i++) {
  41.   for (int j = i+1; j < max; j++) {
  42.   if(i*j/(i+j)==menovatel)
  43.   }
  44.   }*/
  45. for (int i = menovatel+1; i < max; i++) {
  46.  
  47. pom=(menovatel*i*1.0)/(i-menovatel);
  48. if(pom<0 || i>pom)continue;
  49. if(Math.abs(pom-(menovatel*i/(i-menovatel)))<tolerancia){
  50. counter++;
  51. }
  52.  
  53. }
  54. System.out.println(counter);
  55.  
  56. }
  57.  
  58. }
  59. }
  60.  

Diff to submission s706

Main.java

--- c5.s706.cteam085.fl.java.0.Main.java
+++ c5.s711.cteam085.fl.java.0.Main.java
@@ -37,5 +37,5 @@
             //citatel=input.nextInt();
             menovatel=Integer.parseInt(s.substring(2)); //input.nextInt();
-            max=menovatel*10;
+            max=menovatel*3;
       /*      for (int i = menovatel; i < max; i++) {
                 for (int j = i+1; j < max; j++) {