본문 바로가기
Algorithm

[구현/수학] 백준 16693 Pizza Deal - 파이썬(Python)

by jangThang 2022. 8. 2.
반응형

백준 온라인 저지

 

[ Contents ]

     

     

    1. 문제 (링크 참조)

     

    16693번: Pizza Deal

    There’s a pizza store which serves pizza in two sizes: either a pizza slice, with area A1 and price P1, or a circular pizza, with radius R1 and price P2. You want to maximize the amount of pizza you get per dollar. Should you pick the pizza slice or the

    www.acmicpc.net

     

     

     

    2. 문제 풀이

     조각 피자와 피자 한 판 중 단위 용량당 더 싼 걸 고르는 문제입니다.

     일반적으로 생각하면 당연히 피자 한 판이 싸겠으나.... 그렇진 않습니다.

     

     

     

    3. 코드

    from math import pi
    
    # 입력
    A1, P1 = map(int, input().split())
    R1, P2 = map(int, input().split())
    
    # 비교
    if A1/P1 > (R1**2)*pi/P2:
        print("Slice of pizza")
    else:
        print("Whole pizza")

     단순히 3.14와 같은 실수값을 파이로 잡으면 틀립니다. math 라이브러리의 pi상수를 이용해주세요.

     

    star가 되고나서 Tistory

    반응형

    댓글