본문 바로가기
Algorithm

[구현/수학] 백준 19602 Dog Treats - 파이썬(Python)

by jangThang 2022. 8. 17.
반응형

백준 온라인 저지

 

[ Contents ]

     

     

    1. 문제 (링크 참조)

     

    19602번: Dog Treats

    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,

    www.acmicpc.net

     

     

     

    2. 문제 풀이

    1*S + 2*M + 3*L

     S, M, L 사이즈를 가진 간식의 개수가 주어집니다. 간식의 양이 10 이상이어야 happy이고, 미만이면 sad를 출력합니다.

     

     

     

    3. 코드

    # 입력
    s = int(input())
    m = int(input())
    l = int(input())
    
    # 계산
    score = s + 2*m + 3*l
    
    # 출력
    if score >= 10:
        print("happy")
    else:
        print("sad")

     

     

    star가 되고나서 Tistory

    반응형

    댓글