题意:求[a, b]之间差最大/小的相邻素数. 0 < a, b < 2^32, 0 < b - a <= 1e6 首先发现a,b很大,以至于无法求出素数来. 然后就考虑退而求次,求出sqrt(b)以内的素数. 发现可以枚举[a, b]之间的数,还开的下一个vis数组. 然后考虑筛去所有合数. 用sqrt(b)以内的素数筛合数即可. 有两个点要注意: 1,b可能等于2147483647,故for循环里面要写成 i <= b && i > 0 2,注意1不…
题目链接:传送门 题目: Prime Distance Time Limit: 1000MS Memory Limit: 65536K Total Submissions: Accepted: Description The branch of mathematics called number theory and itself). The first prime numbers are ,,, but they quickly become less frequent. One of the…
Prime Distance Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13961 Accepted: 3725 Description The branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the interest of number th…