-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUva389.java
More file actions
30 lines (24 loc) · 913 Bytes
/
Copy pathUva389.java
File metadata and controls
30 lines (24 loc) · 913 Bytes
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
import java.util.*;
import java.io.*;
import java.math.BigInteger ;
public class Uva389
{
public static void main(String[] args) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pr = new PrintWriter(System.out);
StringBuilder sb = new StringBuilder();
while( br.ready() ){
StringTokenizer st = new StringTokenizer(br.readLine());
String num = st.nextToken();
int from = Integer.parseInt(st.nextToken());
int to = Integer.parseInt(st.nextToken());
BigInteger bi = new BigInteger(num,from);
String ans = bi.toString(to).toUpperCase();
sb.append( ans.length() > 7 ? String.format("%7s","ERROR") : String.format("%7s",ans)).append('\n');
}
pr.print(sb.toString());
pr.close();
br.close();
}
}