Sunday, September 6, 2015

460B - Little Dima and Equation (Codeforces)

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define pf printf
#define MX 10005
const double eps = 1e-9;
typedef long long int ll;
ll arr[MX];

int main()
{
    ll a, b, c, x;
    ll temp, i, j=0, sum, temp2;
    cin >>a >> b >> c;
    for(i=1; i<83; i++)
    {
        x = i;
        temp = 0;
        temp = (b*pow(x, a)) + c + eps;

        if(temp>1000000000)
            continue;

        sum = 0;
        temp2 = temp;
        while(temp2!=0)
        {
            sum += temp2%10;
            temp2 /= 10;
        }
        if(sum==x)
            arr[j++] = temp;
    }

    cout << j << endl;
    for(int i=0; i<j ;i++)
        cout << arr[i] << " ";

    return 0;
}


No comments:

Post a Comment

Compare equality of two string in C

#include <stdio.h> #include<string.h> int main() {     char* country = "Bangladesh";     char* country2;     ...