-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ11005.java
More file actions
59 lines (50 loc) · 1.42 KB
/
Copy pathJ11005.java
File metadata and controls
59 lines (50 loc) · 1.42 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
58
59
package TIL;
import java.util.Scanner;
public class J11005 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int cnt = 0;
int largeNumber = scanner.nextInt();
int result = largeNumber;
char[] lastResult;
int keyNumber = scanner.nextInt();
int keyInt;
char keyChar;
for(int i = 0 ; i < 99; i++) {
result = result/keyNumber;
cnt++;
if(result == 0) {
break;
}
}
lastResult = new char[cnt];
int result1 = largeNumber;
for(int i = 0; i <cnt; i++) {
keyInt= result1%keyNumber;
result1 = result1/keyNumber;
if(keyInt> 9) {
keyChar = changeChar(keyInt);
lastResult[cnt-i-1] = keyChar;
}
if(keyInt<10) {
lastResult[cnt - i - 1] = (char) (keyInt + 48);
}
}
for(int i = 0 ; i < lastResult.length; i++) {
System.out.print(lastResult[i]);
}
}
public static char changeChar(int x){
char keyChar;
int intTemp = x;
keyChar = (char) ((x - 10) + 'A');
return keyChar;
}
public static int findPositionNumber(int x, int y){
int result = x;
for(int i = 2; i <y; i ++){
result *= result;
}
return result;
}
}