LeetCode
来源:互联网 发布:2015年疲劳驾驶数据 编辑:程序博客网 时间:2024/05/16 05:33
Description:
Count the number of prime numbers less than a non-negative number, n.
素数筛法。居然还没有忘掉,难得啊。
class Solution {public: int countPrimes(int n) { vector<int> prime; vector<bool> vis(n + 1, false); for (int i = 2; i < n; ++i) { if (vis[i]) continue; vis[i] = true; prime.push_back(i); for (long long j = (long long)i * i; j < n; j += i) { vis[j] = true; } } return prime.size(); }};
阅读全文
0 0
- leetcode
- [leetcode]
- LeetCode
- leetcode
- leetcode
- leetcode:
- leetcode:
- LeetCode
- leetcode
- LEETCODE
- leetcode
- leetCode
- leetcode
- [leetcode]
- LeetCode
- leetcode
- leetcode:
- leetcode
- TCP/IP协议的学习
- 理解Profiles, Services,Characteristics,UUID等值
- 用xshell5连接ubuntu系统教程,以及一些其它的问题
- 【平价数据】SimGAN:活用合成数据和无监督数据
- ScrollView can host only one direct child
- LeetCode
- SQLI labs 第七课(神游太虚)
- 点击事件不响应的问题
- [读书笔记] 《Python 机器学习》
- jquery的一些小小实例
- http://www.imooc.com/note/460?sort=last
- 在 Laravel 5 中使用 Laravel Excel 实现 Excel/CSV 文件导入导出功能
- PAT乙级 1027. 打印沙漏(20)--数学图形找规律
- Java中的字符串