https://pintia.cn/problem-sets/994805342720868352/problems/994805370650738688

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<).

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

代码:

#include <bits/stdc++.h>
using namespace std; int N; int main() {
scanf("%d", &N);
for(int i = 13; i >= 1; i --) {
for(int j = 2; j * j <= N; j ++) {
long long ans = 1;
for(int k = j; k - j <= i - 1; k ++)
ans *= k; if(N % ans == 0) {
printf("%d\n%d", i, j);
for(int k = j + 1; k - j <= i - 1; k ++)
printf("*%d", k); return 0;
}
}
}
printf("1\n%d", N);
return 0;
}

  枚举连续因子长度 枚举起点终点

 

PAT 甲级 1096 Consecutive Factors的更多相关文章

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

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

  2. PAT甲级——A1096 Consecutive Factors【20】

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

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

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

  4. PAT 1096 Consecutive Factors[难]

    1096 Consecutive Factors (20 分) Among all the factors of a positive integer N, there may exist sever ...

  5. 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 ...

  6. PAT 1096. Consecutive Factors

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

  7. 1096. Consecutive Factors (20)

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

  8. 【PAT甲级】1096 Consecutive Factors (20 分)

    题意: 输入一个int范围内的正整数,输出它最多可以被分解为多少个连续的因子并输出这些因子以*连接. trick: 测试点5包含N本身是一个素数的数据,此时应当输出1并把N输出. 测试点5包含一个2e ...

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

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

随机推荐

  1. treap入门

    这几天刚学了treap,听起来还行,就是调题调到恶心了…… 就以这道题作为板子吧(”你本来也就做了一道题!”) https://www.luogu.org/problemnew/show/P3369 ...

  2. 哪些地方会出现css阻塞,哪些地方会出现js阻塞?

    Js的阻塞特性: 所有浏览器在下载JS的时候,会阻止一切其他活动,比如其他资源的下载,内容的呈现等等.直到JS下载.解析.执行完毕后才开始继续并行下载其他资源并呈现内容.为了提高用户体验,新一代浏览器 ...

  3. 或许因为缺少默认route配置而导致的的ping超慢,甚至timeout

    内网有台dell r620 做测试用: 4个网口都插了 网线,通过小交换直接连在中心路由的第3个口上: 安装了kvm,有virbr0   :但还没装其它的虚拟机. ping 外网域名 ,IP地址 都超 ...

  4. Android 写一个Activity之间来回跳转的全局工具类(主要是想实现代码的复用)

    废话不多说了,直接上代码,相信大家都能看得懂的. 一.主要工具类 package com.yw.chat.utils; import android.app.Activity; import andr ...

  5. P3195 [HNOI2008]玩具装箱TOY

    列出DP方程式:设f[i]表示分组完前i件物品的最小花费,为方便计算,设sum[i]表示是前i件物品的长度和. f[i]=min(f[j]+(sum[i]-sum[j]+i-j-L-1)^2) [0& ...

  6. 蓝桥杯历届试题 危险系数(dfs或者并查集求无向图关于两点的割点个数)

    Description 抗日战争时期,冀中平原的地道战曾发挥重要作用. 地道的多个站点间有通道连接,形成了庞大的网络.但也有隐患,当敌人发现了某个站点后,其它站点间可能因此会失去联系. 我们来定义一个 ...

  7. 无法读取配置节“oracle.manageddataaccess.client”,因为它缺少节声明

    程序发布后出现问题: 无法读取配置节“oracle.manageddataaccess.client”,因为它缺少节声明 解决办法: 1.安装了odac12.  ODTwithODAC121010.z ...

  8. 2017-2018-2 20155230《网络对抗技术》实验5:MSF基础应用

    基础问题回答 用自己的话解释什么是exploit,payload,encode. exploit 就是运行该模块吧,在msf的模块中配置好各项属性后exploit一下就开始运行使用该模块了 paylo ...

  9. [清华集训2015 Day2]矩阵变换-[稳定婚姻模型]

    Description 给出一个N行M列的矩阵,保证满足以下性质: M>N. 矩阵中每个数都是 [0,N]中的自然数. 每行中, [1,N]中每个自然数刚好出现一次,其余的都是0. 每列中,[1 ...

  10. ubuntu 桌面操作系统安装WPS办公软件的方法

    1.打开ubuntu系统自带的firefox软件 2.打开linux.wps.cn,并点击立即下载 3. 点击下载deb安装包 4.进入下载目录,sudo dpkg -i wps-office_10. ...