diff --git a/Math/204.Count-Primes/204.Count Primes.cpp b/Math/204.Count-Primes/204.Count Primes.cpp deleted file mode 100644 index 12e036640..000000000 --- a/Math/204.Count-Primes/204.Count Primes.cpp +++ /dev/null @@ -1,25 +0,0 @@ -class Solution { -public: - int countPrimes(int n) - { - if (n<=2) return 0; - - vector num(n - 1, true); - - for (int x = 2; x <= sqrt(n); x++) - { - if (num[x]==false) continue; - - for (int j=2; x*j < n; j++) - num[x*j] = false; - } - - int count=0; - for (int j = 2; j < n; ++j) - { - if (num[j]) count++; - } - - return count; - } -}; diff --git a/Math/204.Count-Primes/204.Count-Primes.cpp b/Math/204.Count-Primes/204.Count-Primes.cpp new file mode 100644 index 000000000..6c7f07dde --- /dev/null +++ b/Math/204.Count-Primes/204.Count-Primes.cpp @@ -0,0 +1,19 @@ +class Solution { +public: + int countPrimes(int n) + { + vectorisPrime(n, true); + int count = 0; + for (int i=2; iq(n,true); -for (x=2; x<=sqrt(n); x++) -{ - if (q[x]==false) continue; - for (int i=2; x*i

AltStyle によって変換されたページ (->オリジナル) /