448 E. Divisors
来源:互联网 发布:php手册 pdf 编辑:程序博客网 时间:2024/06/14 17:01
#include <cstdio>#include <vector>#include <algorithm>using namespace std;const int maxn = 1e5;#define LL long longvector<LL> divi;vector<LL> ans;void solve(LL x,LL k){ if(x==1) { ans.push_back(1); return; } if(k==0) { ans.push_back(x); return; } vector<LL> divs; for(int i=0;i<(int)divi.size()&&divi[i]<=x;++i)//重复利用之前的结果进行计算 { if(x%divi[i]==0) { divs.push_back(divi[i]); } } if(divs.size()==2) { for(int i=0;i<k&&ans.size()<maxn;++i) { ans.push_back(1); } if(ans.size()<maxn) ans.push_back(x); }else { for(int i=0;i<(int)divs.size();++i) { if(ans.size()<maxn) solve(divs[i],k-1); } }}int main(){ LL x,k; scanf("%lld%lld",&x,&k); if(k==0) { printf("%lld\n",x); return 0; } for(LL i=1;i*i<=x;++i) { if(x%i==0) { divi.push_back(i); if(i*i!=x) divi.push_back(x/i); } } sort(divi.begin(),divi.end()); for(int i=0;i<(int)divi.size();++i) { if(ans.size()<maxn) solve(divi[i],k-1); } for(int i=0;i<(int)ans.size();++i) printf("%lld ",ans[i]); puts(""); return 0;}
0 0
- Codeforces 448E Divisors
- 448 E. Divisors
- CodeForces 448 E.Divisors(数论+递归)
- Divisors - CF #256 (Div. 2) E (448E) 暴搜
- codeforces 446E E. Divisors(数论+暴力)
- Codeforces Round #256 (Div. 2) E. Divisors
- Divisors
- Divisors
- Divisors
- CF27.E. Number With The Given Amount Of Divisors
- CF 27E Number With The Given Amount Of Divisors
- 27E - Number With The Given Amount Of Divisors
- Codeforces 27E - Number With The Given Amount Of Divisors
- Codeforces 27E Number With The Given Amount Of Divisors
- Codeforces 27 E Number With The Given Amount Of Divisors
- CodeForces 27E Number With The Given Amount Of Divisors
- Codeforces 703E Mishka and Divisors 离散化+DP
- codeforces 27E Number With The Given Amount Of Divisors
- HDU 4910 Problem about GCD(米勒拉宾)
- php画一个背景透明,且开始处旋转到在圆的正下方处的一个圆饼统计图
- 实现多线程有两种方法: Thread类继承和Runnable接口实现
- 444 C DZY Loves Colors
- 449 C. Jzzhu and Apples
- 448 E. Divisors
- HDU 2276 Kiki & Little Kiki 2 (位运算+矩阵快速幂)
- Android入门中文教程
- HDU 1677 LIS
- fhfh.bmbbhghjgvhj
- Foreman服务器搭建和jenkins plugin的jelly控件添加及问题
- tgfhkfjfkljgljlhdkghfgkfdd
- 使用AIDL实现进程间的通信之复杂类型传递
- WINSOCKS I/O模式