본문 바로가기
Algorithm

[구현/수학] 백준 2975 Transations - 파이썬(Python)

by jangThang 2023. 3. 6.
반응형

백준 온라인 저지

 

[ Contents ]

     

     

    1. 문제 (링크 참조)

     

    2975번: Transactions

    Input consists of a number of lines, each representing a transaction. Each transaction consists of an integer representing the starting balance (between –200 and +10,000), the letter W or the letter D (Withdrawal or Deposit), followed by a second integer

    www.acmicpc.net

     

     

     

    2. 문제 풀이

     은행에서 거래 후 잔고를 구하는 문제입니다.

     

     

    3. 코드

    import sys
    input = sys.stdin.readline
    
    while True:
        a, op, b = input().split()
        if a == b == '0':
            break
        s = int(a)-int(b) if op == 'W' else int(a)+int(b)
        print("Not allowed" if s < -200 else s)

     

     

    star가 되고나서 Tistory

    반응형

    댓글