Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. public class P30 {
  2.  
  3. public static void main(String[] args) {
  4.  
  5. long ans = 0;
  6. for (int i = 2; i < 300000; i++) {
  7. if (i == f(i)) {
  8. ans += i;
  9. }
  10. }
  11.  
  12. System.out.println(ans);
  13. }
  14.  
  15. static int f(int e) {
  16. int sum = 0;
  17. while (e > 0) {
  18. int t = e % 10;
  19. sum += g(t);
  20. e /= 10;
  21. }
  22. return sum;
  23. }
  24.  
  25. static int g(int e) {
  26. return e * e * e * e * e;
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement