일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- BFS
- Combinations
- Zip
- java
- programmers
- lambda
- 이분탐색
- dfs
- divmod
- 수학
- Set
- python
- DateTime
- backjoon
- 다익스트라
- 프로그래머스
- 카카오
- 재귀함수
- 백준
- 위클리 챌린지
- KAKAO BLIND RECRUITMENT
- 파이썬
- 동적 계획법
- 그리디
- heapq
- 정렬
- 정규식
- 자바
- Re
- 추석맞이 코딩챌린지
Archives
- Today
- Total
상상쓰
[백준] 에라토스테네스의 체 본문
https://www.acmicpc.net/problem/2960
2960번: 에라토스테네스의 체
2, 4, 6, 8, 10, 3, 9, 5, 7 순서대로 지워진다. 7번째 지워진 수는 9이다.
www.acmicpc.net
number 배열을 만들어 차례대로 값을 Fasle 로 바꿔가며 K 번째 해당하는 값을 구하면 된다.
import sys, math
N, K = map(int, sys.stdin.readline().split())
answer = 0
number = [True] * (N + 1)
for i in range(2, N + 1):
for j in range(2, N + 1):
if number[j]:
if j % i == 0:
number[j] = False
K -= 1
if K == 0:
print(j)
break
if K == 0:
break
'Coding Test' 카테고리의 다른 글
[백준] 곱셈 (0) | 2021.08.01 |
---|---|
[백준] 명령 프롬프트 (0) | 2021.07.30 |
[프로그래머스] 올바른 괄호의 갯수 (0) | 2021.07.29 |
[프로그래머스] 베스트앨범 (0) | 2021.07.29 |
[프로그래머스] 카펫 (0) | 2021.07.28 |
Comments