본문 바로가기

Algorithm/SWEA

[SWEA] 1926. 간단한 369 게임 D2 JAVA

반응형


문제 이해

 

아이디어

 

코드

import java.util.*;

public class Solution {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for (int i = 1; i <= N; ++i) {
			String tmp = String.valueOf(i);
			int idx = 0, cnt = 0;
			while (idx < tmp.length()) {
				switch (tmp.charAt(idx++)) {
				case '3':
				case '6':
				case '9':
					cnt++;
					break;
				}
			}
			if (cnt > 0) {
				for (int k = 0; k < cnt; ++k)
					System.out.print("-");
				System.out.print(" ");
			} else System.out.print(i+" ");
		}
	}
}

 

 


 

 

집사는개발자가되고파

 

choppadontbiteme.tistory.com

 

반응형