标签存档: Prime Generator

SPOJ Prime Generator 解题报告

2. Prime Generator

Time Limit: 6s Source limit: 50000B

Description

Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate all prime numbers between two given numbers!

Input

The input begins with the number t of test cases in a single line (t<=10). In each of the next t lines there are two numbers m and n (1 <= m <= n <= 1000000000, n-m<=100000) separated by a space.

Output

For every test case print all prime numbers p such that m <= p <= n, one number per line, test cases separated by an empty line.

Sample Input

5 5
2
1 10
3 5

Sample Output

2
3
5
7
 
3
5

最近在看一些有限元方面的书,前人所写的程序几乎清一色的都是用Fortran,所以不得不复习一下Fortran了。据说同样的算法用Fortran实现的会比C/C++实现的快25%(当然我没测试过)。不过要找一个支持Fortran的OJ还真是不容易,因为Poj的Fortran编译器不知道出了什么问题,怎么都编译不了,所以只好选择SPOJ了,不过SPOJ支持的语言还真是多,简直可以说是无所不包。

继续阅读 »