#4256. [GESP202406 八级 C++] 第 13 题

[GESP202406 八级 C++] 第 13 题

下面程序的时间复杂度为( )。

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;
}

{{ select(1) }}

  • O(N)O(N)
  • O(N×logN)O(N \times \log N)
  • O(N×loglogN)O(N \times \log\log N)
  • O(N2)O(N^2)