-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp062.java
More file actions
37 lines (29 loc) · 882 Bytes
/
p062.java
File metadata and controls
37 lines (29 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package level03;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.junit.Test;
import com.google.common.collect.Multimap;
import lib.EulerTest;
public class p062 extends EulerTest {
final int N = 5;
/**
* Find the smallest cube such that exactly N permutations of its digits are also cube.
*/
@Test
public void test() {
Multimap<List<?>, Long> cubes = mmap();
for (int i = 1; true; i++) {
long cube = cb(i);
List<Integer> digits = digits(cube);
Collections.sort(digits);
cubes.put(digits, cube);
Collection<Long> permutations = cubes.get(digits);
if (permutations.size() == N) {
ans = Collections.min(permutations);
break;
}
}
check(127035954683L);
}
}