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. 流式套接字:基于TCP协议的Socket网络编程(案例2)

    案例:在案例1的基础上实现一个服务器对应多个客户端(多线程),且获得每个客户端的IP. 线程代码: package com.yh.mySocket; import java.io.BufferedRe ...

  2. asdm不能登录问题;浏览器必须是ie,不能是chrome或者firefox;java的版本,尤其是安全等级和例外需要调整

    asdm不能登录问题:浏览器必须是ie,不能是chrome或者firefox;java的版本,尤其是安全等级和例外需要调整

  3. 【转】mysql增量备份恢复实战企业案例

    来源地址:http://seanlook.com/2014/12/05/mysql_incremental_backup_example/ 小量的数据库可以每天进行完整备份,因为这也用不了多少时间,但 ...

  4. Python 函数(三)

    Python 3 函数 (闭包.装饰器.递归.高阶函数) 一.闭包 内部函数可以引用外部函数的参数和局部变量,当外部函数返回内部函数时,相关参数和变量 都保存在返回的函数中,简单的说,这种内部函数可以 ...

  5. 关于Flume中Chanel.Selector.header解释

    flume内置的ChannelSelector有两种,分别是Replicating和Multiplexing. Replicating类型的ChannelSelector会针对每一个Event,拷贝到 ...

  6. DQN(Deep Reiforcement Learning) 发展历程(四)

    目录 不基于模型的控制 选取动作的方法 在策略上的学习(on-policy) 不在策略上的学习(off-policy) 参考 DQN发展历程(一) DQN发展历程(二) DQN发展历程(三) DQN发 ...

  7. SonarQube-Centos环境设置为系统服务

    1.准备工作 官方文档:https://docs.sonarqube.org/latest/setup/operate-server/ 2.配置 /sonar.sh /usr/bin/sonar cd ...

  8. 【小程序】本地资源图片无法通过 WXSS 获取

    小程序升级更改: 本地资源图片无法通过 WXSS 获取,可以使用网络图片,或者 base64,或者使用<image/>标签.请参考文档: https://mp.weixin.qq.com/ ...

  9. Codeforces round 1100

    Div 2 532 我对交互一无所知 只能寄期望与NOI和省选不出交互吧... E 这个题,真的是耻辱... 其实非常简单,就是二分+判环... 那么就直接二分答案+拓扑排序即可... (我居然在考试 ...

  10. 20155306 白皎 《网络攻防》 EXP7 网络欺诈技术防范

    20155306 白皎 <网络攻防> EXP7 网络欺诈技术防范 问题回答 (1)通常在什么场景下容易受到DNS spoof攻击 局域网内的攻击以及连接公众场所的共享wifi (2)在日常 ...