fork(3) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4.  
  5. public class Main{
  6. static long c(int n){
  7. List<Long> t = new ArrayList();
  8. for(int i = 2, j; i++ < 30; ){
  9. for(j = 2; j++ < 30; ){
  10. long s = (long) (Math.pow(i, j) + Math.pow(j, i));
  11. if (s < (1L<<31) & !t.contains(s)){
  12. t.add(s);
  13. }
  14. }
  15. }
  16. Collections.sort(t);
  17. return t.get(n);
  18. }
  19.  
  20. public static void main(final String[] a) {
  21. for (int i = 0; i < 14; i += 2) {
  22. System.out.println(c(i));
  23. }
  24. }
  25. }
Success #stdin #stdout 0.11s 320576KB
stdin
Standard input is empty
stdout
54
368
945
2530
6250
18785
23401