#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstring>
using namespace std;
const int maxn=1e5+50;
vector<int> prime;
vector<int> ans;
int n,m,tmp[maxn];
void prepare(int m)
{
int n=floor(sqrt(m)+0.5);
for(int i=2; i<=n; i++)
{
int flag=0;
while(m%i==0)
{
m/=i;
flag=1;
}
if(flag) prime.push_back(i);
}
if(m>1) prime.push_back(m);
}
int main()
{
//freopen("in.in","r",stdin);
//freopen("out.out","w",stdout);
while(scanf("%d%d",&n,&m)==2&&n)
{
prime.clear();
ans.clear();
memset(tmp,1,sizeof(tmp));
prepare(m);
n--;
for(int i=0; i<prime.size(); i++)
{
int p=prime[i];
int need=0;
int x=m,k;
int now=0;
while(x%p==0)
{
need++;
x/=p;
}
for(k=1; k<n; k++)
{
x=n-k+1;
while(x%p==0)
{
now++;
x/=p;
}
x=k;
while(x%p==0)
{
now--;
x/=p;
}
if(now<need) tmp[k]=0;
}
}
for(int i=1; i<n; i++)
if(tmp[i]) ans.push_back(i+1);
printf("%d\n",ans.size());
if(!ans.empty())
{
cout<<ans[0];
for(int i=1;i<ans.size();i++) cout<<" "<<ans[i];
}
cout<<"\n";
}
return 0;
}
UVA 1635(p320)----Irrelevant Elements
最新推荐文章于 2024-01-29 18:47:16 发布