1096. Consecutive Factors
2015-08-30 10:09
447 查看
#include <cstdio> #include <vector> #include <cmath> using namespace std; vector<int>ans ; int main(void) { int num ; int i; scanf("%d" , &num); for( i = 2 ; i <= num; i ++ ) { int j ; int temp = num ; vector<int>tempAns ; if( num/i < i ) break ; for( j = i ; j <= num ; j++) { if( temp%j == 0 ) { temp = temp / j ; tempAns.push_back(j) ; continue ; } else break ; } if( tempAns.size() > ans.size()) { ans.clear(); ans = tempAns ; } } if( ans.size() == 0 ) ans.push_back(num); printf("%d\n" , ans.size()); for( i = 0 ; i < ans.size() - 1 ; i++) { printf("%d*" , ans[i]); } printf("%d\n" , ans[i]); return 0 ; }
相关文章推荐
- 获取单个文件的MD5值
- Android 技巧
- C语言深入
- java数字游戏
- 优先队列的使用
- git合并分支
- String与StringBuffer的区别
- Axis 2 WebService
- 导入导出Android手机文件
- 欢迎使用CSDN-markdown编辑器
- linux 学习笔记之用户管理命令
- 一篇很全面的freemarker教程-初学者必看
- blog第一篇——致梦想
- linux 学习笔记之文件的压缩和解压
- 如何清除SQL Server 2008中登陆时的历史记录
- Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 1) A. Bear and Poker gcd
- c++ 构造函数
- Report, 20150423, On Distance Rate
- 注册“Oracle Provider for OLE DB”和创建链接服务器
- 学习笔记——Android创建应用程序和活动