国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

204. Count Primes

2019-11-08 19:46:59
字體:
來源:轉載
供稿:網友

Description:

Count the number of PRime numbers less than a non-negative number, n.

public class Solution { public int countPrimes(int n) { boolean[] isPrimes = new boolean[n]; int res = 0; for (int i = 2; i < n; i++) isPrimes[i] = true; for (int i = 2; i * i < n; i++) { for (int j = i * i; j < n; j += i) { if (!isPrimes[j]) continue; isPrimes[j] = false; } } for (int i = 2; i < n; i++) { if (isPrimes[i]) res++; } return res; }}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 龙游县| 芜湖市| 博白县| 齐齐哈尔市| 雷山县| 大兴区| 吴忠市| 龙岩市| 彝良县| 青海省| 汉沽区| 靖州| 科尔| 曲靖市| 福贡县| 无棣县| 德庆县| 安平县| 年辖:市辖区| 高邮市| 望奎县| 凤翔县| 溧水县| 芒康县| 乐都县| 伊吾县| 广河县| 澎湖县| 公主岭市| 莱西市| 烟台市| 南投市| 汉源县| 岢岚县| 南开区| 大安市| 余庆县| 福海县| 黄山市| 理塘县| 张家界市|