下面程序的时间复杂度为:
bool notPrime[N] = {false};
void sieve() {
for (int n = 2; n * n < N; n++)
if (!notPrime[n])
for (int i = n * n; i < N; i += n)
notPrime[i] = true;
}
- A. O(N)
- B. O(N×log N)
- C. O(N×log log N)
- D. O(N²)
正确答案:C