Created
January 12, 2019 11:05
-
-
Save developer-sdk/c6b67505177518d507762b278a25076e to your computer and use it in GitHub Desktop.
백준, 4673, 셀프넘버
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
감사합니다 따라 코딩하며 배우고 갑니다!^-^b