Created
October 16, 2013 02:06
-
-
Save cocodrips/7001559 to your computer and use it in GitHub Desktop.
SRM594 div2 500
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashSet; | |
public class AstronomicalRecordsEasy { | |
public int minimalPlanets(int[] A, int[] B) { | |
int min = A.length + B.length - 1; | |
for (int a : A) { | |
for (int b : B) { | |
HashSet<Integer> set = new HashSet<Integer>(); | |
for (int ai = 0; ai < A.length; ai++) { | |
set.add(A[ai] * b); | |
} | |
for (int bi = 0; bi < B.length; bi++) { | |
if (min <= set.size()) { | |
break; | |
} | |
set.add(B[bi] * a); | |
} | |
min = set.size(); | |
} | |
} | |
return min; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment