1 5 4 6 4 7 2 5 1 2 24 1 3 18 2 5 17 3 5 35Sample Output
Yes No No Yes
思路:朴素的想法对N个数分解质因子分别维护前缀和,但是100000范围素数有点多时间不允许,容易发现每个数>sqrt(100000)的质因子至多有一个,那么单独处理这一个就行了,可以用莫队维护或者二分。
# include
# include
# include
# include
using namespace std;
typedef long long LL;
const int maxn = 1e5+30;
int p[maxn], cnt=0, vis[maxn], tot[maxn]={0}, len;
int a[maxn], val[maxn], sum[maxn][66], id[maxn];
int ans[maxn];
inline void scan(int &ret)
{
ret = 0;
char c;
ret = 0;
while ((c = getchar()) < '0' || c > '9');
while (c >= '0' && c <= '9') ret = ret * 10 + (c - '0'), c = getchar();
}
void init()
{
int up = (int)sqrt(100000);
for(int i=2; i<=up; ++i)
{
if(vis[i] == 0)
{
p[++cnt] = i;
id[i] = cnt;
for(int j=i+i; j<=up; j+=i)
vis[j] = 1;
}
}
}
struct node
{
int l, r, id, fk, block;
node(){}
node(int l, int r, int fk, int id):l(l),r(r),fk(fk), id(id){block=l/len;}
bool operator <(const node b) const
{
if(block == b.block) return rl)
{
--L;
++tot[val[L]];
}
while(R>r)
{
--tot[val[R]];
--R;
}
while(L