E. Divisors
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Examples
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 

题意:给你一个数,分解k次;

   每次将每个数分解成它的质因数,个数>=1e5不输出;

思路:枚举质因数,dfs求解,详见代码;

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi (4*atan(1.0))
const int N=2e5+,M=4e6+,inf=1e9+;
ll x,k,flag;
set<ll>s;
set<ll>::iterator it;
ll p[N],len;
void dfs(ll x,ll step)
{
if(step>k)return;
if(flag>=)return;
if(step==k||x==)
{
if(flag>=)return;
printf("%lld ",x);
flag++;
return;
}
for(ll i=;i<len;i++)
{
ll v=p[i];
if(v>x)break;
//cout<<v<<"cccc"<<x<<endl;
if(x%v==)
dfs(v,step+);
}
}
int main()
{
scanf("%lld%lld",&x,&k);
len=;
for(ll i=;i*i<=x;i++)
{
if(i*i==x)
p[len++]=i;
else if(x%i==)
p[len++]=i,p[len++]=x/i;
}
sort(p,p+len);
flag=;
dfs(x,);
return ;
}

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

  1. Codeforces Round #256 (Div. 2) E Divisors

    E. Divisors Bizon the Champion isn't just friendly, he also is a rigorous coder. Let's define functi ...

  2. Codeforces Round #256 (Div. 2)

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

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

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

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

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

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

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

  6. Codeforces Round #256 (Div. 2)总结

    这次CF状态之悲剧,比赛就别提了.后来应该好好总结. A题:某个细节没考虑到,导致T了 代码: #include<cstdio> #include<cstring> #incl ...

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

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

  8. 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 ...

  9. 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 ...

随机推荐

  1. Android开发 adb命令提示:Permission denied (转)

    如题:模拟器版本->android 7.1.1 遇到这样的情况把模拟器root一下就好了:su root =============2017年4月3日20:57:33============== ...

  2. jmeter java 请求 payload

    1.注册页面抓包看见内容如下: POST http://test.nnzhp.cn/bbs/forum.php?mod=post&action=edit&extra=&edit ...

  3. python pymysql安装

    ==================pymysql=================== 由于 MySQLdb 模块还不支持 Python3.x,所以 Python3.x 如果想连接MySQL需要安装 ...

  4. Fiddler 抓取 ios 端数据包

    前提条件: 1. Fiddler 工具安装完成,并授权成功,可以完成网页的http 协议拦截. 2. iphone X 一部 ☺ 3. 360wifi 一个[同一局域网内,任何wifi都可以设置,其他 ...

  5. poj2115[扩展欧几里德]

    C Looooops Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22260   Accepted: 6125 Descr ...

  6. Sum of Remainders(数学题)

    F - Sum of Remainders Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I ...

  7. CSS 布局实例系列(三)如何实现一个左右宽度固定,中间自适应的三列布局——也聊聊双飞翼

    今天聊聊一个经典的布局实例: 实现一个三列布局,其中左侧和右侧的部分宽度固定,中间部分宽度随浏览器宽度的变化而自适应变化 可能很多朋友已经笑了,这玩意儿通过双飞翼布局就能轻松实现.不过,还请容我在双飞 ...

  8. Redis 配置和使用

    Redis的配置 由于Django是动态网站,所有每次请求均会去数据进行相应的操作,当程序访问量大时,耗时必然会更加明显,最简单解决方式是使用:缓存,缓存将一个某个views的返回值保存至内存或者me ...

  9. Linux安装Nignx基于域名的多虚拟主机实战

    看这个文章之前,要保证你的Nginx已经安装成功! 如果没有,请移步到下面这个文章,看完后再回来看! https://www.cnblogs.com/apollo1616/p/10214531.htm ...

  10. windows7下cmd命令窗口没有滚动条的解救方法

    由于昨天的好123问题没有解决,我想查看一下本机的ip地址等,于是打开了cmd窗口,输入ipconfig/all命令进行查看,但是发现出现了下面的窗口,无法进行滚动,完全无法查看详细的信息. 然后我百 ...