Source code for submission s726

Go to diff to previous submission

FL.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.util.HashSet;
  8. import java.util.Scanner;
  9.  
  10. /**
  11.  *
  12.  * @author drevenak3
  13.  */
  14. public class FL {
  15.  
  16. /**
  17.   * @param args the command line arguments
  18.   */
  19. public static void main(String[] args) {
  20. // TODO code application logic here
  21. Scanner vst=new Scanner(System.in);
  22. int N,Y;
  23. while(vst.hasNext()){
  24. HashSet<Long> pairs=new HashSet<Long>();
  25. String ratio = vst.next();
  26. N=Integer.parseInt(ratio.substring(2, ratio.length()));
  27. if(N==1){
  28. System.out.println(1);
  29. continue;
  30. }
  31. int count=0;
  32. long max=((N+1)*N)/2+1;
  33. for(long y,x=N+1;x<=max;++x){
  34. if((N*x)%(x-N)==0){
  35. y=(N*x)/(x-N);
  36. if(!pairs.contains(x)){
  37. pairs.add(x);
  38. pairs.add(y);
  39. ++count;
  40. }
  41. }
  42. }
  43. System.out.println(count);
  44. }
  45. vst.close();
  46. }
  47. }
  48.  

Diff to submission s707

FL.java

--- c5.s707.cteam083.fl.java.0.FL.java
+++ c5.s726.cteam083.fl.java.0.FL.java
@@ -30,6 +30,6 @@
             }
             int count=0;
-            long max=((N+1)*N);
-            for(long y,x=N+1;x<max;++x){
+            long max=((N+1)*N)/2+1;
+            for(long y,x=N+1;x<=max;++x){
                 if((N*x)%(x-N)==0){
                     y=(N*x)/(x-N);