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. Maven常见异常及解决方法(本篇停更至16-4-12)

    本篇文章记录了老猫在学习整合Maven和SSH过程中遇到的问题,有的问题可以解决.有的问题还不能解决. 方法不一定适合全部的环境.但绝对是本人常遇到的常见异常.在这里做一个笔记和记录,也分享给大家,希 ...

  2. atititi.soa  微服务 区别 联系 优缺点.doc

    atititi.soa  微服务 区别 联系 优缺点.doc 1. 应用微服务的动机,跟传统巨石应用的比较1 2. 面向服务架构(SOA)  esb2 3. 微服务架构(Microservices)2 ...

  3. Android遇到的那些坑

    1.输出log Log.i("GOOD",v.getId()+"");

  4. Android程序的打包和安装

    当我们使用Android Studio的时候,这些步骤都交给它去做了. 编译 classes.dex 文件 编译 resources.arsc 文件 生成资源索引表resources.arsc. 把r ...

  5. Hotel poj 3667

    Language: Default Hotel     Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 18020   Acc ...

  6. vmware workstation导出ovf

    ovf tool路径 /Applications/VMware Fusion.app/Contents/Library/VMware OVF Tool 上面红色的部分,需要右键点击应用程序中的VMwa ...

  7. strpos 判断字符串是否存在

    strpos    中为什么要用逗号隔开的原因是因为   防止找出相匹配的中 ,  如   查找1    而数组中  存在  12  那么这个结果也是可以找出来的 ,分别在1 前后加个,  就是为了区 ...

  8. saltstack内置state模块file之append

    添加文件文本在文件尾部 salt.states.file.append(name, text=None, makedirs=False, source=None, source_hash=None, ...

  9. 小贝_php+redis简单实例

    php+redis简单实例 一.说明 因为redis是c/s架构.从这个角度上.不论什么符合redis的client要求的.都能够与redis进行通讯.官方提供了非常多的client. php在web ...

  10. 嵌入式专题: S5PV210 - MPEG4编码

    我想说不台的平台,如tiny210和x210.它们的头文件是有稍微区别的. 我这个是x210下的代码.但都须要注意的是NV12T与NV12的问题,默认要求输入的图片是NV12T,经过调整之后,能够同意 ...