SWEA_1926) 간단한 369게임
SWEA
# D2
1926) 간단한 369게임 (19.10.04)
문제 링크 (SW Expert Academy)
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
31
32
33
|
import java.io.*;
public class Solution {
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int n = Integer.parseInt(br.readLine());
for(int i=1;i<=n;i++) {
String s = String.valueOf(i);
int cnt = 0;
int a =0 ;
for(int j=0;j<s.length();j++) {
a = s.charAt(j)-'0';
if(a%3==0 && a!=0) cnt = cnt+1;
}
if(cnt==0) bw.write(String.valueOf(i));
else {
for(int k=0;k<cnt;k++) {
bw.write("-");
}
}
bw.write(" ");
}
bw.flush();
bw.close();
}
}
| cs |
댓글
댓글 쓰기