Problem A
This problem is a brute force number problem. Given an n-digit number where the digits are d1, d2, ..., dn, the value of that number is d1n + d2n + ... + dnn. We need to find numbers within given bounds such that the value of each number is equal to the respective number.
The values of each possible digits are already predetermined (that is, dn). Therefore, it's plausible guess that there wouldn't be that many numbers. To get a good idea, one can make a program that generate all numbers that satisfy the constraint up until a certain bound, say 1 million. By doing this we find that our guess is quite good. Next step we can do is to generate all the numbers up to 231-1. After that, we store the numbers in a small array, and make the following precalculated program:
#include <stdio.h>
int a[31] = {1, 2, 3, 4, 5, 6, 7, 8, 9,
153, 370, 371, 407, 1634, 8208, 9474,
54748, 92727, 93084, 548834, 1741725, 4210818,
9800817, 9926315, 24678050, 24678051, 88593477,
146511208, 472335975, 534494836, 912985153};
int main()
{
int i,j,k, l = 0;
scanf("%d %d", &j, &k);
for (i = 0; i < 31; i++) if (a[i] >= j && a[i] <= k)
{l = 1; printf("%d\n", a[i]);}
if (!l) printf("None\n");
return 0;
}
Another approach is of course to optimize the brute force program we use to generate the numbers. One of a handful of constraints that we can place on this is that if we have the prefix of a number, say d1, d2, and d3, we can only choose remaining digits such that the value will be less than (d1*100 + d2 * 10 + d3) * 10n - 2.