204. Count Primes
来源:互联网 发布:ipad防沉迷软件 编辑:程序博客网 时间:2024/06/03 18:00
原题
Description:
Count the number of prime numbers less than a non-negative number, n.
代码实现
public int CountPrimes(int n) { int rtncnt = 0; bool[] notPrimes = new bool[n]; for (int i = 2; i < n; i++) { if (notPrimes[i]) continue; rtncnt++; for (int j = 2; i*j < n; j++) { notPrimes[i * j] = true; } } return rtncnt; }
leetcode-solution库
leetcode算法题目解决方案每天更新在github库中,欢迎感兴趣的朋友加入进来,也欢迎star,或pull request。https://github.com/jackzhenguo/leetcode-csharp
2 0
- 204. Count Primes
- 【LeetCode】204.Count Primes
- [leetcode] 204.Count Primes
- LeetCode 204. Count Primes
- Leetcode 204. Count Primes
- 204. Count Primes
- 204. Count Primes
- [LeetCode]204. Count Primes
- 204. Count Primes LeetCode
- 204. Count Primes
- 204. Count Primes
- 204. Count Primes
- 204. Count Primes
- LeetCode *** 204. Count Primes
- 204. Count Primes
- LeetCode 204. Count Primes
- leetcode-204. Count Primes
- 204. Count Primes
- 动态规划9
- 详解Java8特性之Stream API并行流
- 5-1 字符串替换 (10分)
- Distributed File System Learn Test
- 一个简单的java图形
- 204. Count Primes
- 列车车厢重排
- hdoj 6023 Automatic Judge
- 快捷切换hosts小工具:SwitchHosts!
- Github简单介绍及使用(转载知乎用户--珊姗是个小太阳)
- 保存session id的几种方式
- Hibernate hello world
- eclipse 下找不到或无法加载主类的解决办法
- 指针与数组