E. Divisors

Bizon the Champion isn't just friendly, he also is a rigorous coder.

Let's define function f(a), where a is a sequence of integers. Function f(a) returns the following sequence: first all divisors of a1 go in the increasing order, then all divisors of a2 go in the increasing order, and so on till the last element of sequence a. For example, f([2, 9, 1]) = [1, 2, 1, 3, 9, 1].

Let's determine the sequence Xi, for integer i (i ≥ 0): X0 = [X] ([X] is a sequence consisting of a single number X), Xi = f(Xi - 1) (i > 0). For example, at X = 6 we get X0 = [6], X1 = [1, 2, 3, 6], X2 = [1, 1, 2, 1, 3, 1, 2, 3, 6].

Given the numbers X and k, find the sequence Xk. As the answer can be rather large, find only the first 105 elements of this sequence.

Input

A single line contains two space-separated integers — X (1 ≤ X ≤ 1012) and k (0 ≤ k ≤ 1018).

Output

Print the elements of the sequence Xk in a single line, separated by a space. If the number of elements exceeds 105, then print only the first 105 elements.

Sample test(s)
Input
6 1
Output
1 2 3 6 
Input
4 2
Output
1 1 2 1 2 4 
Input
10 3
Output
1 1 1 2 1 1 5 1 1 2 1 5 1 2 5 10 
 #include<stdio.h>
#include<map>
#include<algorithm>
#define MAXN 20000000
using namespace std;
typedef long long LL;
LL ys[];int tot=;int tt2=;
int tail[];int head[];
int aft[MAXN];LL p[MAXN];
LL n,k;
map<LL,int>bh;
void line(int j,int i)
{
tt2++;if(!tail[j])head[j]=tt2;p[tt2]=i;aft[tail[j]]=tt2;tail[j]=tt2;
}
void init()
{
for(LL i=;i*i<=n;i++)
if(n%i==)
{
ys[++tot]=i;
if(i*i!=n)
ys[++tot]=n/i;
}
sort(ys+,ys++tot);
for(int i=;i<=tot;i++)bh[ys[i]]=i;
for(int i=;i<=tot;i++)
for(int j=;j<=i;j++)
if(ys[i]%ys[j]==)line(i,j);
}
int dfs(int now,LL dep,int need)
{
if(ys[now]==)
{
printf("1 ");
return ;
}
if(dep==k)
{
int us=need;
for(int u=head[now];u&&need;need--,u=aft[u])
printf("%I64d ",ys[p[u]]);
return us-need;
}
int us=need;
for(int u=head[now];u&&need;need-=dfs(p[u],dep+,need),u=aft[u]);
return us-need;
}
int main()
{
scanf("%I64d%I64d",&n,&k);if(k>)k=;
init();
if(!k)
{
printf("%I64d\n",n);
return ;
}
dfs(bh[n],,);
return ;
}

Codeforces Round #256 (Div. 2) E Divisors的更多相关文章

  1. Codeforces Round #256 (Div. 2) E. Divisors 因子+dfs

    E. Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...

  2. Codeforces Round #256 (Div. 2) D. Multiplication Table(二进制搜索)

    转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmod ...

  3. Codeforces Round #256 (Div. 2) B. Suffix Structures(模拟)

    题目链接:http://codeforces.com/contest/448/problem/B --------------------------------------------------- ...

  4. Codeforces Round #256 (Div. 2)

    A - Rewards 水题,把a累加,然后向上取整(double)a/5,把b累加,然后向上取整(double)b/10,然后判断a+b是不是大于n即可 #include <iostream& ...

  5. Codeforces Round #256 (Div. 2/B)/Codeforces448B_Suffix Structures(字符串处理)

    解题报告 四种情况相应以下四组数据. 给两字符串,推断第一个字符串是怎么变到第二个字符串. automaton 去掉随意字符后成功转换 array 改变随意两字符后成功转换 再者是两个都有和两个都没有 ...

  6. Codeforces Round #256 (Div. 2) 题解

    Problem A: A. Rewards time limit per test 1 second memory limit per test 256 megabytes input standar ...

  7. Codeforces Round #256 (Div. 2) A. Rewards

    A. Rewards time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  8. Codeforces Round #256 (Div. 2) D. Multiplication Table 二分法

     D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input st ...

  9. Codeforces Round #256 (Div. 2) D. Multiplication Table

    主题链接:http://codeforces.com/contest/448/problem/D 思路:用二分法 code: #include<cstdio> #include<cm ...

随机推荐

  1. fcntl函数的用法总结

    fcntl系统调用可以用来对已打开的文件描述符进行各种控制操作以改变已打开文件的的各种属性 函数原型:   #include<unistd.h> #include<fcntl.h&g ...

  2. MVVM模式的 数据绑定

    数据绑定要达到的效果 数据绑定要达到什么效果呢,就是在界面中绑定了数据源之后,数据在界面上的修改能反映到绑定源,同时绑定源的修改也能反映到界面上.从界面反映到绑定的数据源是很容易理解的,因为在绑定过程 ...

  3. IIS 启用https

    参考:http://www.cnblogs.com/dudu/p/iis_https_ca.html

  4. (六)MyBatis杂项

    第一节:处理CLOB.BLOB类型数据 第二节:传入多个输入参数 第三节:MyBatis分页 1,逻辑分页 2,物理分页 MyBatis默认情况下,MyBatis启用一级缓存,即同一个SqlSessi ...

  5. 插入标识列identity_insert

    插入标识列identity_insert 在进行数据插入时,如果插入列名包括标识列,常常会遇到以下3种提示: 一.“当 IDENTITY_INSERT 设置为 OFF 时,不能向表 'xxxxxxxx ...

  6. RelativeLayout

    <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android=&q ...

  7. Html5和Css3扁平化风格网页

    前言 扁平化概念的核心意义 去除冗余.厚重和繁杂的装饰效果.而具体表现在去掉了多余的透视.纹理.渐变以及能做出3D效果的元素,这样可以让“信息”本身重新作为核心被凸显出来.同时在设计元素上,则强调了抽 ...

  8. 制作Label标签文件时,使用convert_imageset.exe的注意事项

    当前的convert_imageset.exe版本做了一下修改 //status = ReadImageToDatum(root_folder + lines[line_id].first, //li ...

  9. const理解

    const int * a4 = &a1; ///const data,non-const pointer int * const a5 = &a1; ///non-const dat ...

  10. java8的几种常用用法

    1. 如果接口的返回值有可能是null,请用Optional封装 public Optional<User> getUser() { return Optional.ofNullable( ...