blog.itcode.devblog.itcode.dev

[Baekjoon / JAVA] Baekjoon Algorithm 1001 A - B

Write a program that reads two integers A and B, then prints A - B.

[Baekjoon / JAVA] Baekjoon Algorithm 1001 A - B

Write a program that reads two integers A and B, then prints A - B.
RWB0104
@RWBwritten at 2021-05-21 12:51:19
Baekjoon Algorithm

시리즈 모아보기

Baekjoon Algorithm

2 / 22
RankLanguage Used

🖼️ JAVA

🔗 Full Problem 1001

Time LimitMemory Limit
2 sec128MB

Write a program that reads two integers A and B, then prints A - B.

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

Print A - B on the first line.

  • Input

TC

3 2
  • Output

TC

1

This is a subtraction algorithm, only differing from problem 1000 in the operation used. Read two numbers with Scanner, subtract them, and print the result.

JAVA

import java.util.Scanner;

/**
 * Baekjoon Problem 1001 algorithm class
 *
 * @author RWB
 * @see <a href="https://blog.itcode.dev/posts/2021/05/21/a1001">1001 solution</a>
 * @since 2021.04.21 Wed 21:51:19
 */
public class Main
{
	/**
	 * Main function
	 *
	 * @param args: [String[]] parameters
	 */
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		scanner.close();
		
		System.out.println(a - b);
	}
}
  • Math
  • Implementation
  • Arithmetic Operations
# Baekjoon# Algorithm# JAVA# Arithmetic Operations# BRONZE# BRONZE V
ship
blog.itcode.dev

Notes from the π-th Alpaca

7.0.1
Developed by RWB since 2021.057th upgraded at 2026.08