meaning of the title
If the prime factorization of an integer M greater than 1 has k prime numbers, the same can be counted as many. The largest prime factor is Ak, and akk < = N, Ak < 128 is satisfied, we call the integer M as N-pseudosmooth number. Now, let's give N and find the N-pseudosmooth number of K in all integers.
2 ≤ N ≤ 10 ^ 18, 1 ≤ K ≤ 800000, to ensure that at least k numbers meet the requirements
Analysis
It's a very powerful question. It seems that Lord lyc has a more concise approach, but he doesn't understand it.
My% is the master's Title Solution.
It is assumed that f[i,j] represents a set composed of all the numbers of j prime numbers after decomposition, g[i,j] represents a set composed of all the numbers of j prime numbers after decomposition, that is, the prefix sum of f[i,j].
Obviously
f[i,j]=∑g[i−1,j−k]∗pki
g[i,j]=g[i−1,j]+f[i,j]
Here addition represents the union of a set, and multiplication represents the multiplication of each number in a set by a constant.
Obviously, these operations can be implemented with my big parallel heap, as long as the parallel heap can be persisted.
Code
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long LL;
int k,prime[50],tot,sz,f[50][105],g[50][105];
bool vis[130];
LL n;
struct heap{int l,r,dis;LL tag,val;}t[17000005];
priority_queue<pair<LL,pair<int,int> > > que;
void get_prime()
{
for (int i=2;i<128;i++)
if (!vis[i])
{
vis[i]=1;prime[++tot]=i;
for (int j=i*2;j<128;j+=i) vis[j]=1;
}
}
int newnode(int x,LL tag)
{
sz++;t[sz]=t[x];
t[sz].tag*=tag;t[sz].val*=tag;
return sz;
}
void pushdown(int d)
{
if (t[d].tag==1) return;
LL w=t[d].tag;t[d].tag=1;
if (t[d].l) t[d].l=newnode(t[d].l,w);
if (t[d].r) t[d].r=newnode(t[d].r,w);
}
int merge(int x,int y)
{
if (!x||!y) return x+y;
pushdown(x);pushdown(y);
if (t[x].val<t[y].val) swap(x,y);
int v=newnode(x,1);t[v].r=merge(t[v].r,y);
if (t[t[v].l].dis<t[t[v].r].dis) swap(t[v].l,t[v].r);
t[v].dis=t[t[v].l].dis+1;
return v;
}
void prework()
{
get_prime();
g[0][0]=++sz;t[sz].tag=t[sz].val=1;
for (int i=1;i<=tot;i++)
{
g[i][0]=1;
for (LL j=1,pr=prime[i];pr>0&&pr<=n;pr*=prime[i],j++)
{
for (LL k=1,pri=prime[i];k<=j;k++,pri*=prime[i]) f[i][j]=merge(f[i][j],newnode(g[i-1][j-k],pri));
g[i][j]=merge(g[i-1][j],f[i][j]);
que.push(make_pair(t[f[i][j]].val,make_pair(i,j)));
}
}
}
void solve()
{
LL ans;
while (k--)
{
ans=que.top().first;int i=que.top().second.first,j=que.top().second.second;que.pop();
pushdown(f[i][j]);f[i][j]=merge(t[f[i][j]].l,t[f[i][j]].r);
que.push(make_pair(t[f[i][j]].val,make_pair(i,j)));
}
printf("%lld",ans);
}
int main()
{
scanf("%lld%d",&n,&k);
prework();
solve();
return 0;
}