blog.itcode.devblog.itcode.dev

[Baekjoon / JAVA] Baekjoon Algorithm #1008 A / B

Given two integers A and B, write a program that outputs A / B.

[Baekjoon / JAVA] Baekjoon Algorithm #1008 A / B

Given two integers A and B, write a program that outputs A / B.
RWB0104
@RWBwritten at 2021-06-09 01:25:31
Baekjoon Algorithm

시리즈 모아보기

Baekjoon Algorithm

10 / 22
RankLanguage Used

🖼️ JAVA

🔗 Problem #1008

Time LimitMemory Limit
2 sec128MB

Given two integers AA and BB, write a program that outputs A/BA / B.

The first line gives AA and BB. (0<A,B<10)(0 < A, B < 10)

Print A/BA / B on the first line. It's correct as long as the absolute or relative error between the actual answer and the output value is at most 10910^{-9}.

  • Input

TC

1 3
  • Output

TC

0.33333333333333333333333333333333

Allowing an error of up to 10910^{-9} doesn't necessarily mean you must print exactly to the 9th decimal place.

  • Input

TC

4 5
  • Output

TC

0.8

An arithmetic problem following Baekjoon 1000 A + B and Baekjoon 1001 A - B. Hard to get wrong.

For JAVA, just be careful that when you divide with int, only the integer portion is returned, so you must declare the values as a floating-point type such as double before dividing.

JAVA

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Baekjoon problem #1008 algorithm class
 *
 * @author RWB
 * @see <a href="https://blog.itcode.dev/posts/2021/06/09/a1008">1008 solution</a>
 * @since 2021.06.09 Tue 10:23:59
 */
public class Main
{
	/**
	 * Main function
	 *
	 * @param args: [String[]] arguments
	 *
	 * @throws IOException data input/output exception
	 */
	public static void main(String[] args) throws IOException
	{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		
		String[] line = reader.readLine().split(" ");
		
		double a = Double.parseDouble(line[0]);
		double b = Double.parseDouble(line[1]);
		
		System.out.println(a / b);
		
		reader.close();
	}
}
  • Math
  • Implementation
  • Arithmetic
# Baekjoon# Algorithm# JAVA(Java)# Arithmetic# BRONZE# BRONZE IV
ship
blog.itcode.dev

Notes from the π-th Alpaca

7.0.1
Developed by RWB since 2021.057th upgraded at 2026.08