https://www.acmicpc.net/problem/11047
11047번: 동전 0
첫째 줄에 N과 K가 주어진다. (1 ≤ N ≤ 10, 1 ≤ K ≤ 100,000,000) 둘째 줄부터 N개의 줄에 동전의 가치 Ai가 오름차순으로 주어진다. (1 ≤ Ai ≤ 1,000,000, A1 = 1, i ≥ 2인 경우에 Ai는 Ai-1의 배수)
www.acmicpc.net

import sys
n, k = map(int, sys.stdin.readline().split())
coinValue = []
for i in range(n):
coinValue.append( int(sys.stdin.readline().strip()) )
tmValue = k
coinCnt = 0
tmCnt = 0
for i in range(n):
if k >= coinValue[n-1-i]:
tmCnt += (tmValue // coinValue[n-1-i])
tmValue = tmValue % coinValue[n-1-i]
coinCnt += tmCnt
tmCnt = 0
if tmValue == 0:
break
print(coinCnt)
'2022 하반기 > Python' 카테고리의 다른 글
Characteristics of python data type(파이썬 데이터 타입의 특성) (0) | 2023.02.16 |
---|---|
백준 1931 Python (0) | 2023.02.08 |
백준 2750 Python (0) | 2023.02.07 |
백준 1436 Python (0) | 2023.02.07 |
백준 1018 python (0) | 2023.02.02 |
댓글