1096. Consecutive Factors (20)
来源:互联网 发布:淘宝店卖什么好呢 编辑:程序博客网 时间:2024/06/08 06:11
题目:
Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3*5*6*7, where 5, 6, and 7 are the three consecutive numbers. Now given any positive N, you are supposed to find the maximum number of consecutive factors, and list the smallest sequence of the consecutive factors.
Input Specification:
Each input file contains one test case, which gives the integer N (1
解答:
//A1096#include<cstdio>#include<cmath>int main(){ int n; scanf("%d",&n); int first=0,len,maxlen=0,j,tempn; for(int i=2;i<=sqrt(n);i++){ j=i,tempn=n,len=0; while(tempn%j==0){ len++; tempn/=j; j++; } if(maxlen<len){ first=i; maxlen=len; } } if(maxlen==0){ printf("1\n%d",n); }else { printf("%d\n",maxlen); for(int i=0;i<maxlen;i++){ if(i!=0)printf("*"); printf("%d",first+i); } } 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)
- webrtc 编译--终极版
- C
- WebVie加载方式
- Fisher Vector基本原理与用法
- 【bzoj4719】[Noip2016]天天爱跑步
- 1096. Consecutive Factors (20)
- Java相关技术点及技术内容
- 1.1关于数据挖掘
- SpannableString 实现TextView的各种绚丽效果
- C语言_扫雷
- PHP求某二维数组,某一列元素的最大最小值
- Nginx 重启错误
- LUA中的协成特性
- unity坐标点的一些理解