Go to diff to previous submission
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package fl; //import java.util.HashSet; import java.util.ArrayList; import java.util.HashSet; import java.util.Scanner; import java.util.TreeSet; /** * * @author drevenak3 */ public class FL { /** * @param args the command line arguments */ // TODO code application logic here int N,Y; while(vst.hasNext()){ HashSet<Integer> pairs=new HashSet<Integer>(); if(N==1){ continue; } int count=0; //long max=((N+1)*N)/2+1; int max=N*2; for(int y,x=N+1;x<=max;++x){ if((N*x)%(x-N)==0){ y=(N*x)/(x-N); //System.out.print("{"+x+","+y+"};"); if(!pairs.contains(x)){ pairs.add(x); pairs.add(y); ++count; } } } } vst.close(); } }
--- c5.s726.cteam083.fl.java.0.FL.java +++ c5.s769.cteam083.fl.java.0.FL.java @@ -5,6 +5,9 @@ package fl; +//import java.util.HashSet; +import java.util.ArrayList; import java.util.HashSet; import java.util.Scanner; +import java.util.TreeSet; /** @@ -22,5 +25,5 @@ int N,Y; while(vst.hasNext()){ - HashSet<Long> pairs=new HashSet<Long>(); + HashSet<Integer> pairs=new HashSet<Integer>(); String ratio = vst.next(); N=Integer.parseInt(ratio.substring(2, ratio.length())); @@ -30,8 +33,10 @@ } int count=0; - long max=((N+1)*N)/2+1; - for(long y,x=N+1;x<=max;++x){ + //long max=((N+1)*N)/2+1; + int max=N*2; + for(int y,x=N+1;x<=max;++x){ if((N*x)%(x-N)==0){ y=(N*x)/(x-N); + //System.out.print("{"+x+","+y+"};"); if(!pairs.contains(x)){ pairs.add(x);