(백준)Python 11047, 11050, 1541

오성인·2023년 3월 10일
0

알고리즘

목록 보기
6/18
post-custom-banner

https://www.acmicpc.net/problem/11047

N, K = map(int, input().split())
arr = []
count = 0
for _ in range(N):
    arr.append(int(input()))


for i in range(N-1, -1, -1):
    if K >= arr[i]:
        count += K // arr[i]
        K = K % arr[i]
print(count)
    

https://www.acmicpc.net/problem/11050

input = sys.stdin.readline
n, k = map(int, input().split())


def factorial(n):
    answer = 1
    for i in range(1, n+1):
        answer *= i
    return answer

# def factorial_recursion(n):
#     if n == 1:
#         return 1
#     return n * factorial_recursion(n-1)


print(factorial(n)//(factorial(k)*(factorial(n-k))))

https://www.acmicpc.net/problem/1541

sik = input()

result=sik.split('-')

fin=sum(list(map(int, result[0].split('+'))))
for i in range(1,len(result)): 
    fin -= sum(list(map(int, result[i].split('+'))))

print(fin)
profile
기여하는 개발자
post-custom-banner

0개의 댓글