Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- int main() {
- unsigned int N;
- std::cin >> N;
- unsigned int sum = 0;
- for(unsigned int i = 2; i <= 7 * std::pow(9, 6); i++) {
- unsigned int add = 0;
- unsigned int reduce = i;
- while(reduce > 0) {
- unsigned int digit = reduce % 10;
- reduce /= 10;
- unsigned int power = 1;
- for(unsigned int j = 1; j <= N; j++) {
- power *= digit;
- }
- add += power;
- }
- if(add == i) {
- sum += i;
- }
- }
- std::cout << sum << std::endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment