본문 바로가기
Programming/Algorithm(ACM Problems)

[백준] 2420번 : 사파리월드 / [자바] JAVA / 학습기록

by jongmln_ 2022. 1. 20.

https://www.acmicpc.net/problem/2420

 

2420번: 사파리월드

첫째 줄에 두 도메인의 유명도 N과 M이 주어진다. (-2,000,000,000 ≤ N, M ≤ 2,000,000,000)

www.acmicpc.net


[백준] 2420번 : 사파리월드 문제
[백준] 2420번 : 사파리월드 입출력예제


[전체 코드]

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long N = sc.nextLong(); //두 수 Long 타입으로 입력
		long M = sc.nextLong();
		
		System.out.println(Math.abs(N-M));
		//Math.abs는 절대값 변환 함수이다.
	}
	
}

[제출 결과]

제출결과


Math.abs를 알고있다면 매우 쉬운문제.