백준: 19602번 Dog Treats (Python3)
Dog Treats 성공다국어
2 초 | 512 MB | 1214 | 1033 | 974 | 85.289% |
문제
Barley the dog loves treats. At the end of the day he is either happy or sad depending on the number and size of treats he receives throughout the day. The treats come in three sizes: small, medium, and large. His happiness score can be measured using the following formula:
1 × S + 2 × M + 3 × L
where S is the number of small treats, M is the number of medium treats and L is the number of large treats.
If Barley’s happiness score is 10 or greater then he is happy. Otherwise, he is sad. Determine whether Barley is happy or sad at the end of the day.
입력
There are three lines of input. Each line contains a non-negative integer less than 10. The first line contains the number of small treats, S, the second line contains the number of medium treats, M, and the third line contains the number of large treats, L, that Barley receives in a day.
출력
If Barley’s happiness score is 10 or greater, output happy. Otherwise, output sad.
예제 입력 1
3
1
0
예제 출력 1
sad
Barley’s happiness score is 1 × 3 + 2 × 1 + 3 × 0 = 5, so he will be sad.
예제 입력 2
3
2
1
예제 출력 2
happy
Barley’s happiness score is 1 × 3 + 2 × 2 + 3 × 1 = 10, so he will be happy.
답안
1
2
3
4
5
|
S=int(input())
M=int(input())
L=int(input())
print("happy" if (1*S+2*M+3*L)>=10 else "sad")
|
cs |
'공부 > 코딩테스트' 카테고리의 다른 글
백준: 18414번 X に最も近い値 (The Nearest Value) (Python3) (0) | 2022.08.07 |
---|---|
백준: 18698번 The Walking Adam (Python3) (0) | 2022.08.07 |
백준: 19698번 헛간 청약 (Python3) (0) | 2022.08.07 |
백준: 19944번 뉴비의 기준은 뭘까? (Python3) (0) | 2022.08.07 |
백준: 20215번 Cutting Corners (Python3) (0) | 2022.08.07 |
댓글