https://www.acmicpc.net/problem/6763
6763번: Speed fines are not fine!
Many communities now have “radar” signs that tell drivers what their speed is, in the hope that they will slow down. You will output a message for a “radar” sign. The message will display information to a driver based on his/her speed according to
www.acmicpc.net
문제
Many communities now have “radar” signs that tell drivers what their speed is, in the hope that they will slow down.
You will output a message for a “radar” sign. The message will display information to a driver based on his/her speed according to the following table:
km/h over the limit | Fine |
1 to 20 | $100 |
21 to 30 | $270 |
31 or above | $500 |
입력
The input will be two integers. The first line of input will be speed limit. The second line of input will be the recorded speed of the car.
출력
If the driver is not speeding, the output should be:
Congratulations, you are within the speed limit!
If the driver is speeding, the output should be:
You are speeding and your fine is $F.
where F is the amount of the fine as described in the table above.
예제 입력 1
100 131
예제 출력 1
You are speeding and your fine is $500.
예제 입력 2
40 39
예제 출력 2
Congratulations, you are within the speed limit!
예제 입력 3
100 120
예제 출력 3
You are speeding and your fine is $100.
# 첫 번째 줄에 속도 제한을 입력 받고, # 두 번째 줄에 현재 속도를 입력 받는다. # 속도 제한에 따른 현재 속도의 상태를 출력한다. import sys limit = int(sys.stdin.readline()) speed = int(sys.stdin.readline()) sub = limit - speed if sub >= 0: print('Congratulations, you are within the speed limit!') elif sub >= -20: print('You are speeding and your fine is $100.') elif sub >= -30: print('You are speeding and your fine is $270.') else: print('You are speeding and your fine is $500.')
'Problem Solving > BOJ' 카테고리의 다른 글
[백준, BOJ 11866] 요세푸스 문제 0 (python) (0) | 2021.12.17 |
---|---|
[백준, BOJ 6764] Sounds fishy! (python) (0) | 2021.12.16 |
[백준, BOJ 5928] Contest Timing (python) (0) | 2021.12.16 |
[백준, BOJ 11651] 좌표 정렬하기 2 (python) (0) | 2021.12.16 |
[백준, BOJ 5893] 17배 (python) (0) | 2021.12.15 |