Skip to content

Commit 47da8e7

Browse files
authored
Merge pull request #84 from zaqquum/main
Hongjoo/11월 2주차 / 2문제
2 parents 58144f6 + 22dee9a commit 47da8e7

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def one_to_n(n):
2+
return n*(n+1) /2
3+
def solution(a, b):
4+
'''
5+
1~ 5 합 = 1+2+3+4+5 = 15 : n(n+1) /2 = 5*6/2 = 15
6+
'''
7+
# big , small
8+
if a > b :
9+
n=a ; m=b
10+
elif a < b :
11+
n=b ; m =a
12+
else : # a==b
13+
return a
14+
answer = one_to_n(n) - one_to_n(m-1)
15+
16+
return answer

Hongjoo/lv2/최소값만들기.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def solution(A,B):
2+
# 누적 최소값 방법 : 최소 * 최대
3+
'''
4+
5+ 8+16 = 29
5+
4+ 6 = 10
6+
'''
7+
a= sorted(A)
8+
b = sorted(B)
9+
print(b)
10+
answer = 0
11+
for i in range(len(a)):
12+
answer += a[i] * b[-1+ -1*i]
13+
14+
15+
return answer

0 commit comments

Comments
 (0)