题目描述
输入正整数a,b,c 其中$1≤a,b<106,c≤100$输出$a/b$的小数形式,精确到小数点后的c位,例如$a=1,b=6,c=4$输出应该是$0.1667$
输入
多组输入,每行有3个正整数$a,b,c$
输出
输出$a/b$的小数形式,精确到小数点后的c位,
样例输入
1 6 4
1 2 20
样例输出
0.1667
0.50000000000000000000
题解
import java.util.Scanner;
import java.io.BufferedInputStream;
import java.math.RoundingMode;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
public class Main {
static Scanner cin = new Scanner(new BufferedInputStream(System.in));
static PrintWriter cout = new PrintWriter(new BufferedOutputStream(System.out));
public static void main(String[] args) {
while (cin.hasNext()) {
BigDecimal a = cin.nextBigDecimal();
BigDecimal b = cin.nextBigDecimal();
int k = cin.nextInt();
cout.println(a.divide(b, k, RoundingMode.HALF_UP));
}
cin.close();
cout.close();
}
}