[1008] A÷B
Content
Problem link : https://www.acmicpc.net/problem/1008
Problem
After receiving the two integers A and B, write a program that outputs A/B.
Input
A and B are given in the first line. (0 < A, B < 10)
Output
Print A/B on the first line. If the absolute or relative error between the actual correct answer and the output value is 10-9 or less, it is the correct answer.
Answer
#include<iostream>
using namespace std;
int main() {
double a, b = 0;
cin >> a >> b;
printf("%.9lf", a / b);
return 0;
}
If normally using cout
, there is an error even if using cout.precision(9);
. The problem means to print out 9 significant digits, which is not 9 digits below the decimal point, so it may be wrong in solving the problem. We can do cout << fixed << setprecision(9) <<a/b <<endl;
but I went with the simple way.