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. mysql远程连接数据库

    配置mysql允许远程连接的方法. (1)查看3306端口状态 netstat -an | grep 3306 (2)修改mysql配置文件 ubuntu系统:vim /etc/mysql/mysql ...

  2. Runtime - Associated Objects (关联对象) 的实现原理

    主要围绕3个方面说明runtime-Associated Objects (关联对象) 1. 使用场景 2.如何使用 3.底层实现 3.1  实现原理 3.2 关联对象被存储在什么地方,是不是存放在被 ...

  3. Scrapy的【SitemapSpider】的【官网示例】没有name属性

    Windows 10家庭中文版,Python 3.6.4,Scrapy 1.5.0, 上午看了Scrapy的Spiders官文,并按照其中的SitemapSpider的示例练习,发现官文的示例存在问题 ...

  4. 洛谷P3396哈希冲突

    传送门啦 非常神奇的分块大法. 这个题一看数据范围,觉得不小,但是如果我们以 $ \sqrt(x) $ 为界限,数据范围就降到了 $ x < 400 $ 我们设数组 $ f[i][j] $ 表示 ...

  5. 洛谷P2422 良好的感觉

    题目意思就是:最大化一个区间的和与这个区间的最小值的乘积. 换一个角度看问题,如果我们穷举一个最小值 $ a_i $ ,然后往左右扩展,显然是对的,复杂度 $ O(n^2) $.所以我们要优化一下这个 ...

  6. LeetCode664. Strange Printer

    There is a strange printer with the following two special requirements: The printer can only print a ...

  7. Python学习笔记:startswith & endswith 判断开头结尾是否为指定字符串

    作用: 判断字符串是否以指定字符或子字符串结尾,常用于判断文件类型. 如果以指定后缀结尾返回True,否则返回False. 可选参数"start"与"end"为 ...

  8. Hadoop案例(十一)MapReduce的API使用

    一学生成绩---增强版 数据信息 computer,huangxiaoming,,,,,,, computer,xuzheng,,,,, computer,huangbo,,,, english,zh ...

  9. 1926: [Sdoi2010]粟粟的书架

    大概就是分情况乱搞.. 经典维护二维前缀和暴力+莫队算法 垫底QAQ #include <bits/stdc++.h> using namespace std; namespace my_ ...

  10. dubbo的详细介绍

    1.背景 随着互联网的发展,网站应用的规模不断扩大,常规的垂直应用架构已无法应对,分布式服务架构以及流动计算架构势在必行,亟需一个治理系统确保架构有条不紊的演进. 2.架构 单一应用架构 当网站流量很 ...