백준: 20215번 Cutting Corners (Python3)
Cutting Corners 성공스페셜 저지다국어
1 초 | 512 MB | 659 | 580 | 550 | 88.424% |
문제
A large coffee spill in the warehouse of the Busy Association of Papercutters on Caffeine has stained the corners of all paper in storage. In order to not waste money, it was decided that these dirty corners should be cut off of all pieces of paper.
A few members loudly proclaim that cuts should be made diagonally, while other members say that cutting the corner out as a rectangle is the better option. Both parties claim their method is better.
You decide to end this discussion once and for all, telling the rectangle-cutters that their method is slower. You set out to show them the following: given a piece of paper which has a w by h corner that is stained with coffee that needs to be to cut off, how much more effort is it to cut out the whole rectangle compared to cutting along the diagonal?
입력
The input consists of:
- A line containing two integers w and h (1≤w,h≤100 ), representing the width and height of the corner respectively.
출력
Output how much longer you have to cut if you cut out a rectangle, compared to cutting along the diagonal. Your answer should have an absolute or relative error of at most 10−6 .
예제 입력 1
3 4
예제 출력 1
2
예제 입력 2
12 7
예제 출력 2
5.107556011
예제 입력 3
1 1
예제 출력 3
0.585786438
답안
1
2
3
4
5
6
7
|
import math
w, h = map(int, input().split())
rectangleCut = w + h
diagonalCut = math.sqrt(w*w + h*h)
print("%.9f" % (rectangleCut - diagonalCut))
|
cs |
'공부 > 코딩테스트' 카테고리의 다른 글
백준: 19698번 헛간 청약 (Python3) (0) | 2022.08.07 |
---|---|
백준: 19944번 뉴비의 기준은 뭘까? (Python3) (0) | 2022.08.07 |
백준: 20232번 Archivist (Python3) (0) | 2022.08.07 |
백준: 14489번 치킨 두 마리 (...) (Python3) (0) | 2022.08.06 |
백준: 14581번 팬들에게 둘러싸인 홍준 (Python3) (0) | 2022.08.06 |
댓글