니노니나니

[백준/26500번] Absolutely - B4/Python 본문

알고리즘/백준

[백준/26500번] Absolutely - B4/Python

SangJunni 2024. 4. 13. 16:08

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

 

26500번: Absolutely

The first line contains a single positive integer, n, indicating the number of data sets. Each data set is on a separate line and contains two values on the number line, separated by a single space.

www.acmicpc.net

문제

우리는 수직선 상의 두 값 사이의 거리를 절대선 거리라고 부를 것입니다. 두 값이 주어졌을 때, 절대선 거리를 찾아서 반올림하여 한 자리의 정밀도로 형식화하여 출력하세요.

입력

첫 번째 줄에는 데이터 집합의 수를 나타내는 단일 양의 정수 n이 포함되어 있습니다. 각 데이터 집합은 개별 줄에 있으며 수직선 상에 있는 두 값이 하나의 공백으로 구분되어 있습니다.

풀이

n = int(input())
for _ in range(n):
    a,b = map(float, input().split())
    print(f'{abs(a-b):.1f}')

해결방법

단순하게 두 점의 차를 구하면 되는 문제