백준
[4673] 셀프 넘버
by Jcoder
2018. 5. 14.
#include <stdio.h>
int selfNumber(int summ);
int number[10001];
int main()
{
for (int i = 1; i <= 10000; i++)
{
number[selfNumber(i)] = 1;
if (!number[i])
printf("%d\n", i);
}
return 0;
}
int selfNumber(int number1)
{
int res = number1;
if (number1 >= 10000)
{
res += number1 / 10000;
number1 %= 10000;
}
if (number1 >= 1000)
{
res += number1 / 1000;
number1 %= 1000;
}
if (number1 >= 100)
{
res += number1 / 100;
number1 %= 100;
}
if (number1 >= 10)
{
res += number1 / 10;
number1 %= 10;
}
return res += number1;
}