Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class P30 {
- public static void main(String[] args) {
- long ans = 0;
- for (int i = 2; i < 300000; i++) {
- if (i == f(i)) {
- ans += i;
- }
- }
- System.out.println(ans);
- }
- static int f(int e) {
- int sum = 0;
- while (e > 0) {
- int t = e % 10;
- sum += g(t);
- e /= 10;
- }
- return sum;
- }
- static int g(int e) {
- return e * e * e * e * e;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement