PAT 甲级 1096 Consecutive Factors
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的更多相关文章
- PAT甲级——1096 Consecutive Factors (数学题)
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/91349859 1096 Consecutive Factors ...
- PAT甲级——A1096 Consecutive Factors【20】
Among all the factors of a positive integer N, there may exist several consecutive numbers. For exam ...
- PAT Advanced 1096 Consecutive Factors (20) [数学问题-因子分解 逻辑题]
题目 Among all the factors of a positive integer N, there may exist several consecutive numbers. For e ...
- PAT 1096 Consecutive Factors[难]
1096 Consecutive Factors (20 分) Among all the factors of a positive integer N, there may exist sever ...
- 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 ...
- PAT 1096. Consecutive Factors
Among all the factors of a positive integer N, there may exist several consecutive numbers. For exam ...
- 1096. Consecutive Factors (20)
Among all the factors of a positive integer N, there may exist several consecutive numbers. For exam ...
- 【PAT甲级】1096 Consecutive Factors (20 分)
题意: 输入一个int范围内的正整数,输出它最多可以被分解为多少个连续的因子并输出这些因子以*连接. trick: 测试点5包含N本身是一个素数的数据,此时应当输出1并把N输出. 测试点5包含一个2e ...
- PAT (Advanced Level) 1096. Consecutive Factors (20)
如果是素数直接输出1与素数,否则枚举长度和起始数即可. #include<cstdio> #include<cstring> #include<cmath> #in ...
随机推荐
- P3324 [SDOI2015]星际战争
传送门:https://www.luogu.org/problemnew/show/P3324 首先瞅一眼数据范围,发现m, n都很小,所以就可以初步断定这是一道网络流的题. 因为题中说每一个武器只能 ...
- [转]Custom Controls in Visual C# .NET-如何实现自定义控件
A very simple introduction to writing your first .NET control Download source files - 1 Kb Introduct ...
- RPC使用rabbitmq实现
两天时间重写公司架构在本地实现测试学习 双向连接客户端和服务端配置: 连接rabbitmq服务器 定义消息队列 配置发送请求的模板:交换机.消息队列. 配置监听处理:监听的队列.消息转换处理 配置处理 ...
- mysql linux 安装卸载
mysql安装包官网https://dev.mysql.com/downloads/mysql/5.7.html#downloads wget https://dev.mysql.com/get/Do ...
- Php的常见错误及错误分析
我们在进行开发工作的时候,难免会遇到PHP的报错,解决这些错误,也是作为PHPer必须掌握的一种技能. 如果程序发生错误,我们能大致的分析出出现错误的原因,对于我们解决这戏错误会有很大的帮助. Not ...
- 20155304田宜楠《网络对抗技术》Exp1 PC平台逆向破解(5)M
Exp1 PC平台逆向破解(5)M 实践目标 本次实践的对象是一个名为pwn1的linux可执行文件. 该程序正常执行流程是:main调用foo函数,foo函数会简单回显任何用户输入的字符串. 该程序 ...
- EZ 2017 01 07 t
这名字诡异(然而就是这样) 这次主要是yekehe和yu‘ao都来了,所以很开心的讨论(上了200). 但是,yu’ao dalao又AK了!(666666) 不过总体难度也不高,主要是T3没思路. ...
- mfc CListBox
通过ID操作对象 CListBox(列表框)控件 CListBox类常用成员 CListBox插入数据 CListBox删除数据 CListBox运用示例 一.CListBox类常用成员 CListB ...
- CF434D Nanami's Power Plant
就是切糕那道题,首先对每个函数连一串,然后\(x_u\leq x_v+d\)这个条件就是\(u\)函数\(i\)取值连向\(v\)函数\(i-d\)取值边权为inf,然后答案就是最小割了. #incl ...
- Linux部署DotNetCore记录
一.背景 最近半年或最近三个月来,公司在计划大刀阔斧的规划重构新的产品.按目前的计划和宣传还是很令人期待的.前端预计应用现在很流行的前端框架,有Vue.ElementUI等,后端宣传了很多微服务.持续 ...