题目链接:http://lightoj.com/volume_showproblem.php?problem=1197 题意:给你两个数 a b,求区间 [a, b]内素数的个数, a and b (1 ≤ a ≤ b < 231, b - a ≤ 100000). 由于a和b较大,我们可以筛选所有[2, √b)内的素数,然后同时去筛选掉在区间[a, b)的数,用IsPrime[i-a] = 1表示i是素数: ///LightOj1197求区间素数的个数; #include<stdio.h&g…
题目大意: 给出T个实例,T<=200,给出[a,b]区间,问这个区间里面有多少个素数?(1 ≤ a ≤ b < 231, b - a ≤ 100000) 解题思路: 由于a,b的取值范围比较大,无法把这个区间内的所以素数全部筛选出来,但是b-a这个区间比较小,所以可以用区间素数筛选的办法解决这个题目. 代码: #include<cstdio> #include<cstring> #include<iostream> #include<algorith…
E - Help Hanzo Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1197 Description Amakusa, the evil spiritual leader has captured the beautiful princess Nakururu. The reason behind this is he ha…
题目链接:https://vjudge.net/problem/LightOJ-1197 1197 - Help Hanzo PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Amakusa, the evil spiritual leader has captured the beautiful princess Nakururu. The reason behind this is he…