/ hdoj

hdoj-2097 Sky数

// hdoj_2097 Sky数
// 0MS	220K	477 B	GCC

#include <stdio.h>
int fun(int m, int x);
int main(void)
{
	int n, sum10, sum16, sum12;
	while(scanf("%d", &n) && n)
	{
		sum10 = fun(n, 10);
		sum16 = fun(n, 16);
		sum12 = fun(n, 12);
		if(sum10 == sum16 && sum10 == sum12)
			printf("%d is a Sky Number.n", n);
		else
			printf("%d is not a Sky Number.n", n);
	}
	return 0;
}

int fun(int m, int x)
{
    int sum = 0;
    while(m)
    {
        sum += m%x;
        m /= x;
    }
    return sum;
}