Guest User

Untitled

a guest
Feb 16th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. int main() {
  5. unsigned int N;
  6. std::cin >> N;
  7. unsigned int sum = 0;
  8. for(unsigned int i = 2; i <= 7 * std::pow(9, 6); i++) {
  9. unsigned int add = 0;
  10. unsigned int reduce = i;
  11. while(reduce > 0) {
  12. unsigned int digit = reduce % 10;
  13. reduce /= 10;
  14. unsigned int power = 1;
  15. for(unsigned int j = 1; j <= N; j++) {
  16. power *= digit;
  17. }
  18. add += power;
  19. }
  20.  
  21. if(add == i) {
  22. sum += i;
  23. }
  24. }
  25. std::cout << sum << std::endl;
  26. return 0;
  27. }
Add Comment
Please, Sign In to add comment