[PYTHON] 코드업_3301

거스름돈

Posted by iheese on September 04, 2021 · 4 mins read

그리디

나의 시도.. 눈감아

def change(m):
  count=0
  if m>=50000:
   m%=50000
   count+=m//50000
    if m>=10000:
      m%=10000
      count+=m//10000
      if m>=5000:
        m%=5000
        count+=m//5000
        if m>=1000:
          m%=1000
          count+=m//1000
          if m>=500:
            m%=500:
            count+=m//500
            if m>=100:
              m%=100:
              count+=m//100
              if m>=50:
                m%=50:
                count+=m//50
                if m>=10:
                  m%=10:
                  count+=m//10
                else:
                  print(0)
              else:
                print(count+m//10)
            else:
              print(count+)

      else:
        m%=1000
        count+=1000  
  else
  elif m<50000:  나의시도...

def chage(m):
  st50000 = m//50000
  st10000=(m%50000)//10000
  st5000=((m%50000)%10000)//5000
  st1000=(((m%50000)%10000)%5000)//1000
  st100=((((m%50000)%10000)%5000)%1000)//100
  st50=(((((m%50000)%10000)%5000)%1000)%100)//50
  st10=((((((m%50000)%10000)%5000)%1000)%100)%5)//10
  if m>=50000:
    print(st50000+st10000+st5000+st1000+st100+st50+st10)
  elif 50000>m>=10000:
    print(st10000+st5000+st1000+st100+st50+st10)
  elif 10000>m>=5000:
    print(st5000+st1000+st100+st50+st10)
  elif 5000>m>=1000:
    print(st1000+st100+st50+st10)
  elif 1000>m>=100:
    print(st100+st50+st10)
  elif 100>m>=50:
    print(st50+st10)
  else :
    print(st10)
n=int(input())
chage(n) 


change=int(input())
num=0
money = [50000, 10000, 5000, 1000, 500, 100, 50, 10]

for m in money:
  num += change//m
  change=change%m

print(num)

똑똑한 사람이다. 한참 멀었네