博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PAT 1096 Consecutive Factors[难]
阅读量:6565 次
发布时间:2019-06-24

本文共 1481 字,大约阅读时间需要 4 分钟。

1096 Consecutive Factors (20 分)

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<N<231​​).

Output Specification:

For each test case, print in the first line the maximum number of consecutive factors. Then in the second line, print the smallest sequence of the consecutive factors in the format factor[1]*factor[2]*...*factor[k], where the factors are listed in increasing order, and 1 is NOT included.

Sample Input:

630

Sample Output:

35*6*7

 题目大意:给出数N,找出其最长连续因子,因子要从小选起。

//哇好难,越做越难,,,

#include 
#include
#include
using namespace std;int main(){ int n; cin>>n; int m=sqrt(n); int maxl=0,tp=0,bg=0; vector
vt; for(int i=2;i<=m;i++){ int t=n;//这个i表示从哪个地方开始。 if(n%i==0){ tp++; t/=i; if(tp>maxl){ maxl=tp; bg=i;//就是这个开始的时候。但是你得能整除才可以。哇这个好难。 } }else{ tp=0; } } cout<
<<'\n'; for(int i=bg;i

 

//写不下去了,要考虑好多问题啊。 

 

转载于:https://www.cnblogs.com/BlueBlueSea/p/9953447.html

你可能感兴趣的文章
pstree命令
查看>>
css选择器顺序的小技巧
查看>>
C#之自己定义的implicit和explicit转换
查看>>
dojo 学习笔记之dojo.query - query(id) 与query(class)的差别
查看>>
Java基础加强总结(三)——代理(Proxy)
查看>>
一步一步写算法(之hash表)
查看>>
C99规范
查看>>
常用Git代码托管服务分享
查看>>
[转] 电子技术·笔记1(9月份)
查看>>
常用的服务
查看>>
BZOJ3799 : 字符串重组
查看>>
用纯JS做俄罗斯方块 - 简要思路介绍(1)
查看>>
blog摘录--测试感触
查看>>
数据持久化的复习
查看>>
【DeepLearning】Exercise:Sparse Autoencoder
查看>>
Util应用程序框架公共操作类(八):Lambda表达式公共操作类(二)
查看>>
android 设置布局横屏竖屏
查看>>
ThreadLocal
查看>>
FormsAuthentication详解
查看>>
Canvas createRadialGradient API
查看>>