JOJ2573:Product of two primes
来源:互联网 发布:js modem 电话 编辑:程序博客网 时间:2024/05/18 00:44
传送门:http://acm.jlu.edu.cn/joj/showproblem.php?pid=2573
一道求素数的题,因为范围只有20000,可以先把20000以内的符合的预处理出来,预处理加点小技巧,详细见代码。
代码:
#include <cstdio>#include <cstring>using namespace std;int prime[20000];int ans[20000];int main(){ memset(prime, 0, sizeof(prime)); for (int i = 2; i < 200; ++i) //因为是20000以内的,所以处理到200就够了。 for (int j = i; j * i <= 20000; ++j) //按上限枚举 prime[i * j] = 1; for (int i = 2; i < 200; ++i) for (int j = i; j * i <= 20000; ++j) if (!prime[i] && !prime[j]) ans[i * j] = 1; for (int i = 10000; i < 20000; ++i) if (ans[i]) printf("%d\n", i); return 0;}
- JOJ2573:Product of two primes
- joj2573
- Primes Product
- Problem 10 of Find the sum of all the primes below two million.
- summation of four primes
- Sum of Consecutive Primes
- Sum of Different Primes
- Sum of Consecutive Primes
- 【Leetcode】238-Product of Array Except Self【Java实现】【Medium】【two way traverse】
- 371. Sum of Two Integers\318. Maximum Product of Word Lengths\208. Implement Trie\201.Bitwise AND
- 1259. Sum of Consecutive Primes
- Problem 10:Summation of primes
- 110705 Summation of Four Primes
- Summation of Four Primes - PC110705
- Problem 10:Summation of primes
- UVa1213 Sum of Different Primes
- sicily1259 Sum of Consecutive Primes
- PE 10 Summation of primes
- 5个Ajax最佳实践
- the evil cmake -- string concatenation
- 推荐系统:主要推荐方法
- Java GUI之创建一个长宽尺寸为屏幕尺寸一半的框架,并显示在屏幕的正中心
- 看图学中文版VS2010 Workflow 4.0 (三)
- JOJ2573:Product of two primes
- Spring里的IOC例子
- 苹果官方文档-线程编程指南之一:介绍
- the evil VC -- Visual C++ project, macro, output file
- PHP内核介绍及扩展开发指南—基础知识
- 键盘符号的英文读法
- PHP内核介绍及扩展开发指南—Extensions 的编写
- The evil CMake -- File system, path notation, slash
- 出租房的照片