https://www.acmicpc.net/problem/4673
#include <iostream>
#include <string>
#define MAX_NUM 10000
using namespace std;
int selfNum(int num)
{
int sum = num;
int d = num;
do{
sum += d%10;
d = d/10;
}while(d!=0);
return sum;
}
int main(void)
{
int n = 1;
bool selfChk[MAX_NUM+1] = {false};
for( int i=1; i <= MAX_NUM; i++ )
{
int ret = selfNum(i);
if( ret <= MAX_NUM )
selfChk[ret] = true;
}
for( int i=1; i <= MAX_NUM; i++ )
{
if( !selfChk[i] )
cout << i << endl;
}
return 0;
}
self number ๊ตฌํ๋๊ฑฐ๋ ๋ฐฐ์ด์ ๊ฒฐ๊ณผ ์ ์ฅํ๋๊ฑฐ๋ง
ํ ์ ์์ผ๋ฉด ๊ธ๋ฐฉํ ์ ์์ ๊ฒ ๊ฐ์ ๋ฌธ์ ๋ค
๊ธ์์๋ ์ง์ค์ด ์ง์ง ์๋๋ค
๊ฐ๋จํ๊ฑด๋ฐ ๋ช๋ถ์ด ๊ฑธ๋ฆฐ๊ฑฐ์งใ ใ ;
'๐Algorithm ------------ > ๋ฐฑ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๋ฐฑ์ค 11720๋ฒ: ์ซ์์ ํฉ(Python) (0) | 2021.06.01 |
---|---|
๋ฐฑ์ค 11654๋ฒ: ์์คํค ์ฝ๋ (Python) (0) | 2021.06.01 |
๋ฐฑ์ค 8958๋ฒ: OX ํด์ฆ (C++) (0) | 2021.05.21 |