Lesson 11. Sieve of Eratosthenes - CountSemiPrimes #1
1. 문제A prime is a positive integer X that has exactly two distinct divisors: 1 and X. The first few prime integers are 2, 3, 5, 7, 11 and 13.A semiprime is a natural number that is the product of two (not necessarily distinct) prime numbers. The first few semiprimes are 4, 6, 9, 10, 14, 15, 21, 22, 25, 26.You are given two non-empty arrays P and Q, each consisting of M integers. These arrays rep..
Lesson 11. Sieve of Eratosthenes - CountNonDivisible #1
1. 문제You are given an array A consisting of N integers.For each number A[i] such that 0 ≤ i For example, consider integer N = 5 and array A such that:A[0] = 3A[1] = 1A[2] = 2 A[3] = 3 A[4] = 6For the following elements:A[0] = 3, the non-divisors are: 2, 6,A[1] = 1, the non-divisors are: 3, 2, 3, 6,A[2] = 2, the non-divisors are: 3, 3, 6,A[3] = 3, the non-divisors are: 2, 6,A[4] = 6, there aren't..
Lesson 10. Prime and composite numbers - Peaks #2 (속도 개선-1)
1. 이전 코드 문제점나누어진 각 블럭에 peak값이 있는지 확인하기 위해, peak 배열을 전체 탐색하고 있다.예제를 3개의 블럭으로 나눴을 때, 각 블럭에 peak가 있는지, 없는지 어떻게 확인하는지 자세히 뜯어보자.A[0]A[1]A[2]A[3]A[4]A[5]A[6]A[7]A[8]A[9]A[10]A[11]123434123462 index로 나타내면 다음과 같다. block: (0, 1, 2, 3), (4, 5, 6, 7), (8, 9, 10, 11)peak: (3, 5, 10) 첫번째 블럭: peak index 3 포함됨두번째 블럭: peak index 3 미포함 / peak index 5 포함세번째 블럭: peak index 3 미포함 / peak index 5 미포함 / peak index 10..