Skip to content

Instantly share code, notes, and snippets.

@developer-sdk
Created January 12, 2019 11:05
Show Gist options
  • Select an option

  • Save developer-sdk/c6b67505177518d507762b278a25076e to your computer and use it in GitHub Desktop.

Select an option

Save developer-sdk/c6b67505177518d507762b278a25076e to your computer and use it in GitHub Desktop.
백준, 4673, 셀프넘버
package sdk.backjun;
/**
* 백준, 4673
* 셀프 넘버
*
* @author whitebeard-k
*
*/
public class Problem4673 {
static int N = 10000;
static int[] hasConst = new int[N + 1];
public static void main(String[] args) {
for (int i = 1; i <= N; i++) {
checkSelfNumber(i);
}
for (int i = 1; i <= N; i++) {
if (hasConst[i] == 0)
System.out.println(i);
}
}
// number가 생성자인 숫자 체크
public static void checkSelfNumber(int number) {
int sum = number;
while (number != 0) {
int mod = number % 10;
number /= 10;
sum += mod;
}
if (sum <= N)
hasConst[sum] = 1;
}
}
@NamBoongEh
Copy link
Copy Markdown

감사합니다 따라 코딩하며 배우고 갑니다!^-^b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment