-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmento11005.java
More file actions
57 lines (45 loc) ยท 1.75 KB
/
mento11005.java
File metadata and controls
57 lines (45 loc) ยท 1.75 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package backjoon;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
// https://www.acmicpc.net/problem/11005
public class mento11005 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] input = sc.nextLine().split(" ");
sc.close();
int n = Integer.parseInt(input[0]);
int b = Integer.parseInt(input[1]);
List<Character> list = new ArrayList<>();
while(n > 0) {
if (n % b < 10) {
list.add((char) (n % b + '0'));
} else { // ๋๋จธ์ง๊ฐ 10์ด์์ด๋ฉด A(10) B(11) C(12) ... Z(35)
list.add((char) (n % b - 10 + 'A'));
}
n /= b; // b๋ก ๊ณ์ ๋๋๊ธฐ
}
//์ถ๋ ฅ
for(int i=0; i<list.size(); i++){
System.out.print(list.get(i));
}
/* //๊ดํธ์ ์ค์์ฑ
System.out.println((char) 9+'0'); //57
System.out.print((char) (9+'0')); //9
//10๋ณด๋ค ์์ ์ ํ
์คํธ
System.out.print((char) (8+'0')); //8
System.out.print((char) (7+'0')); //7
System.out.print((char) (6+'0')); //6
System.out.print((char) (5+'0')); //5
System.out.print((char) (4+'0')); //4
System.out.print((char) (3+'0')); //3
System.out.print((char) (2+'0')); //2
System.out.print((char) (1+'0')+"\n"); //1
//์ซ์๋ฅผ char๋ก ๋ํ๋ด๊ณ ์ถ์๋๋ (char) ํ๋ณํ
System.out.println((char) 65); //A
//char๋ฅผ ์์คํค์ฝ๋๋ก ๋ํ๋ด๊ณ ์ถ์๋๋ ์ซ์๋ฅผ ๋ํ ๊ฒ
System.out.println('A'+1); //66
//์์ ๋ ๋ฐฉ๋ฒ ํฉ์ณ์๋ ๊ฐ๋ฅ
System.out.println((char) ('A'+1)); //B*/
}//end of main()
}