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<2​31​​).

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:

3
5*6*7

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

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

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

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

PAT 1096 Consecutive Factors[难]的更多相关文章

  1. PAT 1096. Consecutive Factors

    Among all the factors of a positive integer N, there may exist several consecutive numbers. For exam ...

  2. PAT甲级——1096 Consecutive Factors (数学题)

    本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/91349859 1096 Consecutive Factors  ...

  3. PAT (Advanced Level) Practise - 1096. Consecutive Factors (20)

    http://www.patest.cn/contests/pat-a-practise/1096 Among all the factors of a positive integer N, the ...

  4. PAT 甲级 1096 Consecutive Factors

    https://pintia.cn/problem-sets/994805342720868352/problems/994805370650738688 Among all the factors ...

  5. PAT Advanced 1096 Consecutive Factors (20) [数学问题-因子分解 逻辑题]

    题目 Among all the factors of a positive integer N, there may exist several consecutive numbers. For e ...

  6. 1096. Consecutive Factors (20)

    Among all the factors of a positive integer N, there may exist several consecutive numbers. For exam ...

  7. PAT A1096 Consecutive Factors (20 分)——数字遍历

    Among all the factors of a positive integer N, there may exist several consecutive numbers. For exam ...

  8. PAT (Advanced Level) 1096. Consecutive Factors (20)

    如果是素数直接输出1与素数,否则枚举长度和起始数即可. #include<cstdio> #include<cstring> #include<cmath> #in ...

  9. PAT甲题题解-1096. Consecutive Factors(20)-(枚举)

    题意:一个正整数n可以分解成一系列因子的乘积,其中会存在连续的因子相乘,如630=3*5*6*7,5*6*7即为连续的因子.给定n,让你求最大的连续因子个数,并且输出其中最小的连续序列. 比如一个数可 ...

随机推荐

  1. thinkphp 集成 twig模版引擎

    下载地址:https://github.com/fucongcong/ThinkPHPLevel/archive/master.zip 控制器格式为: <?php namespace Home\ ...

  2. SQL on Hadoop 的真相(1)

    转自:http://blog.jobbole.com/86710/ 这是一组系列博文,目的是详尽介绍 SQL-on-Hadoop .本系列的第一篇会介绍 Hadoop 系统的存储引擎和在线事务处理(简 ...

  3. 嵌入式开发之davinci--- 8148/8168/8127 中的图像处理算法优化库vlib

    The Texas Instruments VLIB is an optimizedImage/Video Processing Functions Library for C programmers ...

  4. PyQt的Layout的比例化分块。

    一. QGridLayout: // 列比 第0列与第1列之比为 1:2 layout2p1 -> setColumnStretch(0, 1); layout2p1 -> setColu ...

  5. css 动画

    CSS3动画相关的几个属性是:transition, transform, animation:我分别理解为过渡,变换,动画.虽意义相近,但具体角色不一.就像是SHE组合,虽然都是三个女生,都唱同一首 ...

  6. 隐马尔可夫树(HMT模型)

    HMT(Hidden Markov Tree)隐马尔可夫树 [论文] 小波变换与HMT模型的图像插值算法-郭昌-中山大学学报(自然科学版)

  7. Python 读取json文件

    创建json文件: { "fontFamily": "微软雅黑", "fontSize": 12, "BaseSettings&q ...

  8. Java千百问_05面向对象(011)_引用传递和值传递有什么差别

    点击进入_很多其它_Java千百问 1.什么是值传递 值传递,是将内存空间中某个存储单元中存放的值,传送给还有一个存储单元.(java中的存储单元并不是物理内存的地址,但具有相关性) 比如: //定义 ...

  9. Struts2_day03--OGNL的#、%使用

    OGNL的#.%使用 #使用 1 使用#获取context里面数据 2 演示# 操作 (1)向request域放值 (2)在页面中使用ognl获取 %使用 1 在struts2标签中表单标签 (1)在 ...

  10. iOS开发之-- 设置启动图片

    一.添加启动图片 点击Assets.xcassets进入图片管理,右击,弹出"New Launch Image"或点下面的+号创建Launch Image: 如图,右侧的勾选可以让 ...