3301 : 거스름돈

n = int(input())
c1 = c2= c3 = c4 = c5 = c6 = c7 = c8 = 0
while n >= 50000:
    c1 = c1 + 1
    n = n - 50000
while n >= 10000:
    c2 = c2 + 1
    n = n - 10000  
while n >= 5000:
    c3 = c3 + 1
    n = n - 5000
while n >= 1000:
    c4 = c4 + 1
    n = n - 1000
while n >= 500:
    c5 = c5 + 1
    n = n - 500
while n >= 100:
    c6 = c6 + 1
    n = n - 100
while n >= 50:
    c7 = c7 + 1
    n = n - 50
while n >= 10:
    c8 = c8 + 1
    n = n - 10
print(c1+c2+c3+c4+c5+c6+c7+c8)
        

3120 : 리모컨 

a,b = map(int,input().split())
sum = 0
target11 = abs(a-b)
while target11 != 0:
  if target11 >= 8:
    target11 = abs(target11 - 10)
    sum = sum+1
  elif target11 <8 and target11 >=3:
    target11 = abs(target11 - 5)
    sum = sum+1
  elif target11 <3 and target11 >=1:
    target11 = abs(target11 - 1)
    sum = sum+1
print(sum)

(codeup) 2001 : 최소 대금

pasta1 = int(input())
pasta2 = int(input())
pasta3 = int(input())
juice1 = int(input())
juice2 = int(input())

costPasta=min(pasta1, pasta2, pasta3)
costJui = min(juice1, juice2)
result = (costPasta+costJui)*1.1
print ("%.1f"%result)

1912 : (재귀함수) 팩토리얼 계산

n = int(input())
def factorial(n,res):
  if n == 1:
    print(res)
  else:
    res = res * n
    factorial(n-1,res)
    
  
res=1
factorial(n,res)

1905 : (재귀함수) 1부터 n까지 합 구하기

import sys
sys.setrecursionlimit(1000000)
a=int(input())

def sumNto1(a,sum2):
  if a==0:
    print(sum2)
  else:
    sum2 += a
    sumNto1(a-1,sum2)
sum2=0
sumNto1(a,sum2)

1904 : (재귀함수) 두 수 사이의 홀수 출력하기

a,b=map(int,input().split())
def odd(a,b):
  if b<a:
    return 0
  elif b % 2 != 0:
    odd(a,b-1)
    print(b)
  elif b % 2 == 0:
    odd(a,b-1)
odd(a,b)
  
    
  
    
    
    

+ Recent posts