I tried to construct a mathematical question too much at the beginning. I found that I couldn't do it. Now I 've been busy completing the question and finally completed it. I went to the next big case study, I found it was followed by "1". I think it should be a mathematical thinking question. I must deal with "1", and it must be 1 if K exceeds 100000, because each time K starts from 0, if K is 1 larger than the original one, it will certainly be 1 more than the original one, so 10 ^ 5 will certainly have 10 ^ 5 1, if K is 0, it must be n itself. The rest of the data is decomposed by N from the very beginning. Of course, there is no need for prime number decomposition. I have nothing to worry about, let's just break it down. Take a closer look at the f (x [I-1]). Thank you very much, if you write seven or eight answers, you will find that each part of the answers is definitely a factor of N, but there are some problems in order. At the beginning, all the factors are sorted in order, then, because the f (x) function breaks down the N factor step by step to get the next answer, you can add a large factor if it is able to remove a small one, finally, it is the problem of output processing,
Unfortunately, I couldn't handle the problem for a long time due to my lack of IQ. The so-called "DFS Tree" of these companies could not be referenced in the end. I thought that even if I had made a reference, I wrote it for a long time, A good question. Add it to your favorites. I will try again later.
Title: http://codeforces.com/contest/448/problem/E
#include<iostream>#include<cstdio>#include<list>#include<algorithm>#include<cstring>#include<string>#include<queue>#include<stack>#include<map>#include<vector>#include<cmath>#include<memory.h>#include<set>#define ll long long#define eps 1e-8const int inf = 0xfffffff;const ll INF = 1ll<<61;using namespace std;//vector<pair<int,int> > G;//typedef pair<int,int > P;//vector<pair<int,int> > ::iterator iter;////map<ll,int >mp;//map<ll,int >::iterator p;ll fac[1000000 + 5];ll n,k;ll tot = 0ll;vector<ll> G[1000000 + 5];void init() {for(ll i=1;i * i <= n;i++) {if(n%i == 0) {fac[tot++] = i;if(i * i != n)fac[tot++] = n / i;}}sort(fac,fac + tot);}int mark = 0;void dfs(ll pos,ll now) {if(mark >= 100000)return;if(pos == 0ll) {printf("1 ");mark++;return;}if(now == 0ll) {printf("%I64d ",fac[pos]);mark++;return ;}for(ll i=0ll;i<G[pos].size();i++) {dfs(G[pos][i],now - 1);if(mark >= 100000 )return ;}}int main() {while(scanf("%I64d %I64d",&n,&k) == 2) {init();if(k == 0) {printf("%I64d\n",n);continue;}if(k >= 100000) {if(n == 1)puts("1");else {for(int i=1;i<=100000;i++) printf("%d%c",1,i == 100000?'\n':' ');}continue;}int cnt = 0;for(ll i=0ll;i<tot;i++) {for(ll j=0ll;j<=i;j++) if(fac[i]%fac[j] == 0) {G[i].push_back(j);++cnt;}}dfs(tot - 1,k);puts("");}return 0;}