1096. Consecutive Factors (20)
来源:互联网 发布:毕业生自我鉴定知乎 编辑:程序博客网 时间:2024/06/10 05:25
#include<cstdio>#include<math.h>int main(){ long long len=0,best_len=0,ans = 0,best_ans=0,x=2,temp=0,y=2; long long num=0,back=0; scanf("%lld",&back); num = back; temp = (long long)sqrt(1.0*num); len=0;best_len=0;ans = 0;best_ans=0;x=2;y=2; while(x<=temp) { y = x; len = 0; num = back; while((num % y) == 0) //寻找连续因子 { len++; num = num/y; y++; } if(len>best_len) //记录更长的 { best_len = len; best_ans = x; } x++; } if(best_len == 0) //特殊情况 { printf("1\n%lld",num); } else { printf("%lld\n",best_len); for(int i=0; i<best_len; i++) { if(i == 0) printf("%lld",best_ans); else printf("*%lld",best_ans+i); } } printf("\n"); return 0;}
0 0
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- Gson的使用
- Python的基础性东西学习
- Linux开发基础:Shell编程入门(一)
- int与string的相互转换
- 1099. Build A Binary Search Tree (30)
- 1096. Consecutive Factors (20)
- HDU1016:Prime Ring Problem(DFS)
- Oracle 12C 新特性之表分区或子分区的在线迁移
- 1097. Deduplication on a Linked List (25)
- Service的两种启动方式和对应的生命周期
- (14)关卡编辑器之图层
- Linux开发基础:Shell编程入门(二)
- 1098. Insertion or Heap Sort (25)
- 1099. Build A Binary Search Tree (30)