정답코드 :
# 브론즈 1
arr = list(map(int,input().split()))
'''
수를 상정하고 하나씩 더해가면서
5개의 수를 계속 나눠 보면서 count 해서 3개 이상일 경우
'''
n = 1
while True:
cnt = 0
for i in arr:
if n % i ==0:
cnt += 1
if cnt >= 3:
print(n)
break
n += 1
틀린풀이 2
16% 시간초과
cnt ==3 을 해서 예외가 발생했는 문제 발생
# 브론즈 1
arr = list(map(int,input().split()))
n = 1
while True:
cnt = 0
for i in arr:
if n % i ==0:
cnt += 1
if cnt == 3:
print(n)
break
n += 1
틀린 풀이 : 카운팅 배열을 만들고 배수를 더해나가다가 cnt이 3이 됐을 때 출력 하려했음
cnt = [0] * (10**6)
flag = 0
for j in range(1,100):
for i in arr:
cnt[i*j] += 1
# print(cnt[i*j])
if cnt[i*j] == 3:
flag = 1
print(i*j)
break
if flag:
break
print(cnt)
'알고리즘 문제풀이' 카테고리의 다른 글
백준 1157 단어공부 Python 구현 문자열 브론즈 1 (0) | 2024.03.11 |
---|---|
백준 2443. D-day Python 구현 실버5 (0) | 2024.03.11 |
백준 2443 별찍기-6 Python 구현 브론즈3 (0) | 2024.03.10 |
백준 2869 달팽이는 올라가고 싶다 Python 수학 브론즈1 (0) | 2024.03.09 |
백준 4673 셀프 넘버 Python 수학 구현 브루트포스 실버5 (0) | 2024.03.09 |