题目链接:http://poj.org/problem?id=2689 Time Limit: 1000MS Memory Limit: 65536K Description The branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the interest of number theoreticians for thousan…
找素数本来是很简单的问题,但当数据变大时,用朴素思想来找素数想必是会超时的,所以用素数筛法. 素数筛法 打表伪代码(用prime数组保存区间内的所有素数): void isPrime() vis[]数组清零://vis[]数组用于标记是否已被检验过 prime[]数组全赋初值false://prime[]数组从下标0开始记录素数 for i = 2 to MAXN (i++) if 数i未被检验过 prime[tot++]=i; for j = i*i to MAXN (j+=i) //j是i的…