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. 不要以为字段以transient修饰的话就一定不会被序列化

    1: 先阅读这边文章:http://www.importnew.com/21517.html 2:被transient修饰真的会被序列化吗? 反例:java.util.ArrayList中底层存储数组 ...

  2. RedHat Enterprise Linux 6.4使用Centos 6的yum源问题

    RedHat Enterprise Linux 6.4使用Centos 6的yum源问题 作为一名新手,学习Linux已经一个月了,其间遇到了不少问题,而今天笔者遇到的问题是 #yum install ...

  3. laytpl js模板引擎

    laytpl js模板引擎.laytpl是一款非常轻量的JavaScript模板引擎.地址:http://www.layui.com/laytpl/ 用法与handlebar.js类似,但是比较轻量级 ...

  4. abp 模块系统

    abp模块系统:ABP理论学习之模块系统 ABP提供了构建模块并将这些模块组合起来创建应用的基础设施.一个模块可以依赖另一个模块.一般来说,一个程序集可以认为是一个模块.一个模块是由一个派生了AbpM ...

  5. [浅谈CSS核心概念] CSS元素类型和盒模型

    元素类型 在CSS中,HTML标签元素分为三种类型: 块状元素 内联元素(也叫行内元素) 内联块状元素 它们之间的区别在于: 块级元素会独占一行,内联元素和内联块状元素则都会在一行内显示 块状元素和内 ...

  6. sphinx搜索 笔记

    架构图: 安装sphinx,见文章http://my.oschina.net/ptk/blog/495435 sphinx关键的配置文件.在里面写查询的sql. 两个关键命令:indexer生成查询索 ...

  7. SQL Server 启动时发生错误1069:由于登录失败而无法启动

    解决方法:    (1). 我的电脑--控制面板--管理工具--服务--右键MSSQLSERVER--属性--登陆--登陆身份--选择"本地系统帐户".    (2). 我的电脑- ...

  8. Android开发——JobScheduler机制

    年Google开发大会上指出,如果每个APP都使用这个API,那么可以节约15%到20%的电量. 2.  JobScheduler拥有更多的触发选项 JobScheduler比AlarmManager ...

  9. POJ 2299

    上课讲了下数据结构,因为暂时没找到分块的板子题,所以做一下这道题加深一下对树状数组的理解. 题意就是求逆序对,从逆序对的定义就可以看出,方法有两种:归并 or 树状数组. 感觉树状数组更高级一点,写起 ...

  10. mfc 友元类

    知识点 继承类成员的访问级别 友元类 继承访问控制: 基类 派生类(能否访问) public private protected 派生类类 派生类对象 派生类 派生类对象 派生类类 派生类对象 pri ...