-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUva748.java
More file actions
44 lines (40 loc) · 1.44 KB
/
Uva748.java
File metadata and controls
44 lines (40 loc) · 1.44 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
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.io.*;
public class Uva748
{
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());
double x = Double.parseDouble(st.nextToken());
int y = Integer.parseInt(st.nextToken());
BigDecimal bd = new BigDecimal(Double.toString(x));
String s = bd.pow(y).toString();
String front = "" ;
int front_idx = -1 ;
for(int i = 0 ; i < s.length() ; i++){
if( s.charAt(i) == '.' ){
front = s.substring(0,i);
front_idx = i ;
} else if( s.charAt(i) == 'E' ){
String end = s.substring(front_idx+1,i);
int num = Integer.parseInt( s.substring(i+2,s.length()) );
s = "." ;
for (int j = 0; j < num-front.length() ; j++) {
s += '0' ;
}
s += front+end ;
}
}
sb.append(s).append('\n');
}
pr.print(sb.toString());
pr.close();
br.close();
}
}