Codeforces_460_B

http://codeforces.com/problemset/problem/460/B

 

枚举s(X)。

 

#include<cstdio>
#include<iostream>
using namespace std;

int fun(int a)
{
    int sum = 0;
    while(a)
    {
        sum += a%10;
        a /= 10;
    }
    return sum;
}

int main()
{
    int a,b,c,num = 0;
    scanf("%d%d%d",&a,&b,&c);
    long long ans[81];
    for(int i = 1;i <= 81;i++)
    {
        int sum = b;
        for(int x = 0;x < a;x++)
        {
            sum *= i;
        }
        sum = sum+c;
        if(sum > 1e9)
        {
            break;
        }
        if(fun(sum) == i)
        {
            ans[num++] = sum;
        }
    }
    printf("%d\n",num);
    for(int i = 0;i < num;i++)
    {
        if(i == num-1)
        {
            printf("%d\n",ans[i]);
        }
        else
        {
            printf("%d ",ans[i]);
        }
    }
    return 0;
}

 

posted @ 2016-09-14 14:52  zzzzzzzzhu  阅读(127)  评论(0编辑  收藏  举报