Appoint description:
Description
![Download as PDF Download as PDF](https://i-blog.csdnimg.cn/blog_migrate/2ea975a8d421ce3226c46b0946fd5932.png)
Input
Input file contains several datasets. Each datasets has n and m ( 1![$ \le$](https://i-blog.csdnimg.cn/blog_migrate/e3cc0f5df575962c4fb4c6ba7b724ddc.png)
![$ \le$](https://i-blog.csdnimg.cn/blog_migrate/e3cc0f5df575962c4fb4c6ba7b724ddc.png)
![$ \le$](https://i-blog.csdnimg.cn/blog_migrate/e3cc0f5df575962c4fb4c6ba7b724ddc.png)
![$ \le$](https://i-blog.csdnimg.cn/blog_migrate/e3cc0f5df575962c4fb4c6ba7b724ddc.png)
Output
On the first line of the output for each dataset print the number of irrelevant elements of the initial array for given n and m. On the second line print all such i that i-th element is irrelevant. Numbers on the second line must be printed in the ascending order and must be separated by spaces.Sample Input
3 2
Sample Output
1 2
紫书例题。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
int n, m;
int cnt;
bool ok;
vector<int> q, e;
vector<int> ans;
void add_integer()
{
int len=sqrt(m)+1;
for(int i=2;i<=len;i++){
if(m%i==0) {
e.push_back(0);
while(m%i==0){
e[e.size()-1]++;
m/=i;
}
q.push_back(i);
//m/=i;
if(!m) return ;
}
}
if(m!=1) {
e.push_back(1);
q.push_back(m);
}
}
bool judge(int k, int p)
{
int len= q.size();
bool ok=true;
for(int i=0;i<len;i++){
while(k&&k%q[i]==0){
e[i]-=p;
k/=q[i];
}
if(ok&&e[i]>0) ok=false;
}
if(ok) return true;
return false;
}
void solve()
{
q.clear();
e.clear();
ans.clear();
add_integer();
ok=false;
cnt=0;
for(int i=1;i<n;i++){
judge(n-i+1, 1);
if(judge(i, -1) ){
cnt++;
ans.push_back(i+1);
}
}
}
int main()
{
while(cin>>n>>m){
n-=1;
//cout<<++kase<<endl;
solve();
int len = ans.size();
cout<<cnt<<endl;
for(int i=0;i<len ;i++){
if(!i) cout<<ans[i];
else cout<<" "<<ans[i];
}
cout<<endl;
}
return 0;
}