코딩 및 기타

오일러1081,1082,1083

정지홍 2023. 1. 20. 01:22

#1081 동전 교환 : 오일러OJ (euleroj.io)

#탐욕 알고리즘
y=int(input())
x=1000-y
c500=500
c100=100
c50=50
c10=10
c5=5
c1=1
rst=0#거스름 동전수
while(x!=0):
    if x>=c500:
        rst+=1
        x=x-c500
    elif x>=c100:
        rst+=1
        x=x-c100
    elif x>=c50:
        rst+=1
        x=x-c50
    elif x>=c10:
        rst+=1
        x=x-c10
    elif x>=c5:
        rst+=1
        x=x-c5
    else:
        rst+=1
        x=x-c1
print(rst)

#1082 The King : 오일러OJ (euleroj.io)

x=int(input())#왕의 자식수
y=int(input())#거듭제곱 수
son=list(map(int,input().split()))#자식의 지능 수
max=0#지능 수의 최대 합

for i in range(0,x):
    z=son[i]**y
    if z>0:
        max+=z
    

print(max)
 
r,m,y=map(int,input().split())#이율,자금,년도
r=r*0.01
r=r+1
for i in range(0,y):
    m=m*r
m=int(m)
print(m)