Go to diff to previous submission
import java.util.HashSet; import java.util.Scanner; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author kajanek6 */ public class Fl { HashSet<Integer> mnozina=new HashSet<Integer>(); int n=0; int counter=0; int y=0; while (input.hasNextLine()) { counter=0; for(int i=1;i<=10000;i++) { if((i-n)>0){ int vysl = (n*i)/(i-n); int zvysok=(n*i)%(i-n); if(vysl>0 && zvysok==0) { if(!mnozina.contains(i)){ counter++; mnozina.add(i); mnozina.add(vysl); } } } } } } public class pair{ public int prvy; public int druhy; public pair(int a,int b){ prvy=a; druhy=b; } } }
--- c5.s679.cteam087.fl.java.0.Fl.java +++ c5.s715.cteam087.fl.java.0.Fl.java @@ -16,24 +16,24 @@ public static void main(String[] args) { - HashSet<Double> mnozina=new HashSet<Double>(); - double n=0; + HashSet<Integer> mnozina=new HashSet<Integer>(); + int n=0; int counter=0; - double y=0; + int y=0; Scanner input = new Scanner(System.in); while (input.hasNextLine()) { counter=0; String temp = input.nextLine(); - n=Double.parseDouble(temp.substring(2)); - for(double i=1;i<10000;i++) + n=Integer.parseInt(temp.substring(2)); + for(int i=1;i<=10000;i++) { if((i-n)>0){ - double vysl = n*i/(i-n); - //System.out.println(Math.abs(vysl-Math.round(vysl))); - if(vysl>0 && Math.abs(vysl-Math.round(vysl))<0.0001) + int vysl = (n*i)/(i-n); + int zvysok=(n*i)%(i-n); + if(vysl>0 && zvysok==0) { if(!mnozina.contains(i)){ counter++; mnozina.add(i); - mnozina.add((double)Math.round(vysl)); + mnozina.add(vysl); }