-
알고리즘 & 자료구조 스터디(10조) 1일차알고리즘 2023. 5. 23. 15:09
Q.4948 베르트랑 공준
- 소수인지 아닌지를 구하는 함수를 적용시켜서 구해보았지만 정답이 아니다 수정을 좀 더 진행 한 후 안되면 어쩔 수 없지...
def sosu(x): for i in range(2, x): if x % i == 0: return False return True x = int(input()) count = 0 for i in range(x, (2 * x) + 1): if sosu(i): count += 1 print(count)
Q.2869 달팽이는 올라가고 싶다
- 시간초과라고 하는데 줄여봐야겠다. 반복문 아니라 다른 것을 이용하는 지 고민이 된다.
x, y, z = map(int, input().split()) start = 0 count = 0 while True: start + x if start == z: break count += 1 start - y print(count)
'알고리즘' 카테고리의 다른 글
알고리즘 & 자료구조 스터디(10조) 6일차 (0) 2023.05.27 알고리즘 & 자료구조 스터디(10조) 5일차 (0) 2023.05.26 알고리즘 & 자료구조 스터디(10조) 4일차 (1) 2023.05.25 알고리즘 & 자료구조 스터디(10조) 3일차 (0) 2023.05.24 알고리즘 & 자료구조 스터디(10조) 2일차 (0) 2023.05.23