当前位置:网站首页>【PTA】L1-006 连续因子
【PTA】L1-006 连续因子
2022-04-23 20:20:00 【也许会吧】
原题链接
ac代码
注意注释当中的易错点和优化方法
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<map>
using namespace std;
int main() {
int n;
cin >> n;
int len = 0, st = 0;
for(int i = 2; i <= sqrt(n); i++) {
//sqrt(n)之后不可能有连续因子
int temp = n;
if(!(temp % i)) {
int templ = 0, tempst = i;
int t = i;//因为是分组因子,所以可能存在把前面去掉,加上后面,连续因子更多的情况,用t暂代i
while(!(temp % t)) {
//此处连续因子指的不是所用能整除的因子,而是分组的
temp /= t++;
templ++;
}
if(templ > len) {
len = templ;
st = tempst;
}
}
}
if(len) {
cout << len << endl;
for(int i = st; i < st + len - 1; i++) {
cout << i << '*';
}
cout << st + len - 1;
}else{
cout << 1 << endl << n;//质数找不到中间因子,之前的查找不会记录,单独输出个数1和它自身
}
return 0;
}
版权声明
本文为[也许会吧]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_55475680/article/details/124353348
边栏推荐
- Sqoop imports tinyint type fields to boolean type
- Cadence OrCAD capture batch change component packaging function introduction graphic tutorial and video demonstration
- Recommend an open source free drawing software draw IO exportable vector graph
- Historical track data reading of Holux m1200-e Bluetooth GPS track recorder
- 2022 - Data Warehouse - [time dimension table] - year, week and holiday
- ArcGIS js api 4. X submergence analysis and water submergence analysis
- CVPR 2022 | QueryDet:使用级联稀疏query加速高分辨率下的小目标检测
- Why does ES6 need to introduce map when JS already has object type
- Intersection calculation of straight line and plane in PCL point cloud processing (53)
- R language ggplot2 visual facet_wrap, and use the lineheight parameter to customize the height of the facet icon tab (gray label bar)
猜你喜欢
PIP installation package reports an error. Could not find a version that satisfies the requirement pymysql (from versions: none)
Mysql database backup scheme
16MySQL之DCL 中 COMMIT和ROllBACK
SQL Server Connectors By Thread Pool | DTSQLServerTP 插件使用说明
Leetcode XOR operation
[target tracking] pedestrian attitude recognition based on frame difference method combined with Kalman filter, with matlab code
Some basic configurations in interlij idea
Numpy mathematical function & logical function
STM32 Basics
selenium. common. exceptions. WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT
随机推荐
R语言使用timeROC包计算无竞争风险情况下的生存资料多时间AUC值、使用confint函数计算无竞争风险情况下的生存资料多时间AUC指标的置信区间值
[problem solving] 'ASCII' codec can't encode characters in position XX XX: ordinal not in range (128)
selenium. common. exceptions. WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT
nc基础用法2
Azkaban recompile, solve: could not connect to SMTP host: SMTP 163.com, port: 465 [January 10, 2022]
论文写作 19: 会议论文与期刊论文的区别
【问题解决】‘ascii‘ codec can‘t encode characters in position xx-xx: ordinal not in range(128)
Mysql database - single table query (I)
Fundamentals of programming language (2)
Openharmony open source developer growth plan, looking for new open source forces that change the world!
Recommend an open source free drawing software draw IO exportable vector graph
Es index (document name) fuzzy query method (database name fuzzy query method)
Livego + ffmpeg + RTMP + flvjs to realize live video
Introduction to electron Tutorial 4 - switching application topics
R语言ggplot2可视化分面图(facet_wrap)、使用lineheight参数自定义设置分面图标签栏(灰色标签栏)的高度
MySQL advanced lock - overview of MySQL locks and classification of MySQL locks: global lock (data backup), table level lock (table shared read lock, table exclusive write lock, metadata lock and inte
Redis的安装(CentOS7命令行安装)
NC basic usage 2
The market share of the financial industry exceeds 50%, and zdns has built a solid foundation for the financial technology network
STM32基础知识