Go to diff to previous submission
import java.io.*; import java.util.*; public class Fl { //Scanner sc = new Scanner(new BufferedReader(new FileReader(new File("in.txt")))); int i = 1; while (sc.hasNextLine()) { sc.nextLine(); if (n == 1) { continue; } int x = n + 1; double y = (n*x)/ (double) (x-n); int sum = 0; List<Integer> list = new ArrayList<Integer>(); for (; ; x++) { // y < n +1 y = (n*x)/ (double) (x-n); if (y <= n+1) break; if ((int) y - y == 0) { if (list.contains((int) y)) break; sum++; list.add(x); } } } } }
--- c5.s572.cteam054.fl.java.0.Fl.java +++ c5.s611.cteam054.fl.java.0.Fl.java @@ -1,5 +1,4 @@ -import java.io.BufferedReader; -import java.io.InputStreamReader; +import java.io.*; import java.util.*; @@ -7,13 +6,16 @@ public class Fl { - public static void main(String[] args) { - System.out.println(); + public static void main(String[] args) throws FileNotFoundException { + + Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in))); + //Scanner sc = new Scanner(new BufferedReader(new FileReader(new File("in.txt")))); + int i = 1; - Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in))); + while (sc.hasNextLine()) { - while (sc.hasNextLine()) { int n = Integer.parseInt(sc.next().substring(2)); - sc.nextLine(); + sc.nextLine(); + if (n == 1) { @@ -22,4 +24,6 @@ } + + int x = n + 1; @@ -28,14 +32,15 @@ int sum = 0; - List<Integer> list = new ArrayList<Integer>(); - + List<Integer> list = new ArrayList<Integer>(); for (; ; x++) { // y < n +1 y = (n*x)/ (double) (x-n); - + + if (y <= n+1) break; if ((int) y - y == 0) { if (list.contains((int) y)) break; + sum++; list.add(x); @@ -45,4 +50,5 @@ System.out.println(sum); + } }