<문제> 곱하기 혹은 더하기
s = '02984'
s = list(s)
max = 0
for i in range(len(s)):
if s[i] != '0' and s[i] != '1':
if max != 0:
max *= int(s[i])
else:
max += int(s[i])
else:
max += int(s[i])
print(max)
<문제> 모험가 길드
Fear = [2,3,1,2,2]
N = len(Fear)
Fear = sorted(Fear)
Fearless = []
group = 0
for i in Fear:
Fearless.append(i)
if len(Fearless) >= i:
group += 1
Fearless = []
print(group)
'Python > 알고리즘(Python)' 카테고리의 다른 글
5. 그리디 문제 풀이(3) (0) | 2023.03.02 |
---|---|
4. 그리디 문제 풀이(2) (0) | 2023.02.17 |
2. 그리디 (0) | 2023.02.17 |
10. 파이썬 문법 - 실전에서 유용한 표준 라이브러리 (0) | 2023.02.16 |
9. 파이썬 문법 - 함수 (0) | 2023.02.16 |
Uploaded by Notion2Tistory v1.1.0