Notice
Recent Posts
Recent Comments
Link
- Today
- Total
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 코틀린
- posting
- jlpt
- Android
- pullrequest
- ai
- rxjava
- PR
- coroutine
- 진짜학습지후기
- Kotlin
- 일본어기초
- suspend
- 안드로이드
- github
- 인공지능
- errorhandling
- androidstudio
- 책추천
- n3문법
- blog
- 일본어문법
- webflux
- 책리뷰
- 학습지
- KotlinInAction
- GIT
- 진짜학습지
- CustomTab
- 진짜일본어
Archives
코딩하는 개굴이
BaekJoon/BOJ [JAVA] 셀프 넘버_4673 본문
반응형
BaekJoon/BOJ [JAVA] 셀프 넘버_4673
HINT: 크기가 10000이기 때문에, 시간에 쫓기지 않아도 된다! 배열에 넣어서 셀프넘버가 아닌 수들을 1로 표시 해 주었다.
import java.util.ArrayList;
public class baekjoon_4673 {
public static void main(String argv[]) {
int array[] = new int[10050];
final int not_selfnumber = 1;
final int selfnumber = 0;
int i=0;
while(i<=10000){
int total=i;
total+=decompose(i);
array[total]=not_selfnumber;
i++;
}
i=1;
while(i<=10000) {
int tmp = array[i];
if(tmp == selfnumber) System.out.println(i+"");
i++;
}
}
public static int decompose(int num) {
int total=0;
while(num>=1) {
total += (num%10);
num/=10;
}
return total;
}
}
반응형
'알고리즘 > Baekjoon' 카테고리의 다른 글
BaekJoon/BOJ [JAVA] 단어의 개수_1152 (1) | 2019.01.03 |
---|---|
BaekJoon/BOJ [JAVA] 한수_1065 (0) | 2019.01.03 |
BaekJoon/BOJ [JAVA] 더하기 사이클_1110 (0) | 2018.11.25 |
BaekJoon/BOJ [JAVA] 시험 성적_9498 (0) | 2018.11.25 |
BaekJoon/BOJ [JAVA] 평균_1546 (0) | 2018.11.25 |
Comments