알고리즘 및 자료구조/문제
백준알고리즘 4673번 셀프 넘버
ktko
2018. 5. 1. 11:24
백준알고리즘
https://www.acmicpc.net/problem/4673
그냥 계산하면되 ..
public class Main { public static void main(String[] args) { int array[] = new int[10001]; for(int i=1; i<= array.length; i++) { int result = calculate(i); if(result <= 10000) { array[result] = 1; } } for(int i=1; i< array.length; i++) { if(array[i] != 1) { System.out.println(i); } } } public static int calculate(int value) { int result = value; while(value > 0) { result += value % 10; value /= 10; } return result; } }