-
Notifications
You must be signed in to change notification settings - Fork 4
/
p029.java
42 lines (33 loc) · 866 Bytes
/
p029.java
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
38
39
40
41
42
import java.math.BigInteger;
import java.util.*;
/**
*
* @author gouravrusiya
*
*/
public class p029 {
public static void main(String [] args){
long startTime = System.currentTimeMillis();
BigInteger a = new BigInteger("2");
BigInteger limit = new BigInteger("100");
BigInteger val = new BigInteger("1");
ArrayList<BigInteger> array = new ArrayList<BigInteger>();
for(int j=2;j<=100;){
for(int b=2;b<=100;b++){
val = a.pow(b);
//System.out.println(val);
array.add(val);
}
j++;
a = a.add(BigInteger.ONE);
}
HashSet<BigInteger> hs = new HashSet<BigInteger>();
hs.addAll(array);
array.clear();
array.addAll(hs);
int itemCount = array.size();
System.out.println(itemCount);
long endTime = System.currentTimeMillis();
//System.out.println("Took "+(endTime - startTime) + " ms");
}
}