Codeforces Round #256 (Div. 2) 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.
A single line contains two space-separated integers — X (1 ≤ X ≤ 1012) and k (0 ≤ k ≤ 1018).
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.
6 1
1 2 3 6
4 2
1 1 2 1 2 4
10 3
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的更多相关文章
- 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 ...
- Codeforces Round #256 (Div. 2) D. Multiplication Table(二进制搜索)
转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmod ...
- Codeforces Round #256 (Div. 2) B. Suffix Structures(模拟)
题目链接:http://codeforces.com/contest/448/problem/B --------------------------------------------------- ...
- Codeforces Round #256 (Div. 2)
A - Rewards 水题,把a累加,然后向上取整(double)a/5,把b累加,然后向上取整(double)b/10,然后判断a+b是不是大于n即可 #include <iostream& ...
- Codeforces Round #256 (Div. 2/B)/Codeforces448B_Suffix Structures(字符串处理)
解题报告 四种情况相应以下四组数据. 给两字符串,推断第一个字符串是怎么变到第二个字符串. automaton 去掉随意字符后成功转换 array 改变随意两字符后成功转换 再者是两个都有和两个都没有 ...
- Codeforces Round #256 (Div. 2) 题解
Problem A: A. Rewards time limit per test 1 second memory limit per test 256 megabytes input standar ...
- 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 ...
- 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 ...
- Codeforces Round #256 (Div. 2) D. Multiplication Table
主题链接:http://codeforces.com/contest/448/problem/D 思路:用二分法 code: #include<cstdio> #include<cm ...
随机推荐
- Android Bander设计与实现 - 设计
Binder Android IPC Linux 内核 驱动 摘要 Binder是Android系统进程间通信(IPC)方式之一.Linux已经拥有管道,system V IPC,socket等IPC ...
- 金蝶K3,名称或代码在系统中已被使用,由于数据移动,未能继续以NOLOCK方式扫描
使用金蝶K3时出现:名称或代码在系统中已被使用:错误代码:3604(E14H)source:Microsoft OLE DB provider for SQL SERVERDetail:由于数据移动, ...
- 空洞卷积(dilated Convolution) 与感受野(Receptive Field)
一.空洞卷积 空洞卷积是是为了解决基于FCN思想的语义分割中,输出图像的size要求和输入图像的size一致而需要upsample,但由于FCN中使用pooling操作来增大感受野同时降低分辨率,导致 ...
- idea添加jdbc包
IDEA版本:IDEA 14 这里我使用的第三方jar包是数据库的JDBC jar包导出案例. 1.创建一个Module,名称为dataBase,在里面我们先创建一个folder用来包含所需要的jar ...
- C# byte[] 转换16进制字符串
1.byte[] 转换16进制字符串 1.1 BitConverter方式 var str = DateTime.Now.ToString(); var encode = Encoding.UTF8; ...
- Docker - CentOS安装Docker
如果要在CentOS下安装Docker容器,必须是CentOS 7 (64-bit).CentOS 6.5 (64-bit) 或更高的版本,并要求 CentOS 系统内核高于 3.10. uname ...
- 用户说体验 | 关于阿里百川HotFix你需要了解的一些细节
最近很火的热修复技术,无意中了解到阿里百川也在做,而且Android.iOS两端都支持,所以决定试一试.试用一段时间后,感觉还不错,主要是他们有一个团队在不断维护更新这个产品,可以看到他们的版本更新记 ...
- 2016-2017-2 20155309南皓芯《java程序设计》第七周学习总结
教材学习内容总结 Lambda 一种匿名方法 表达式构成 括号以及括号里用逗号分隔的参数列表 仅有一个参数的可以省略括号 ->符号 花括号以及花括号里的语句 仅有一条语句时可以省略花括号,并且这 ...
- entityframework导航属性筛选
); //会在sql代码中生成Street = "上海"代码 var address1 = db.Entry(user).Collection(b => b.Address) ...
- CF 586B 起点到终点的最短路和次短路之和
起点是右下角 终点是左上角 每次数据都是两行的点 输入n 表示有n列 接下来来的2行是 列与列之间的距离 最后一行是 行之间的距离 枚举就行 Sample test(s) input 41 ...