当前位置:网站首页>【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
边栏推荐
- Mysql database and table building: the difference between utf8 and utf8mb4
- WordPress插件:WP-China-Yes解决国内访问官网慢的方法
- Redis distributed lock
- nc基础用法2
- VeraCrypt文件硬盘加密使用教程
- Use the rolling division method to find the maximum common divisor of two numbers
- SQL Server Connectors By Thread Pool | DTSQLServerTP 插件使用说明
- NC basic usage
- selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT
- DTMF dual tone multi frequency signal simulation demonstration system
猜你喜欢
![[target tracking] pedestrian attitude recognition based on frame difference method combined with Kalman filter, with matlab code](/img/30/39de1628cb47f715056fb898955ff5.png)
[target tracking] pedestrian attitude recognition based on frame difference method combined with Kalman filter, with matlab code

DNS cloud school | analysis of hidden tunnel attacks in the hidden corner of DNS

Leetcode dynamic planning training camp (1-5 days)
![[graph theory brush question-5] Li Kou 1971 Find out if there is a path in the graph](/img/fb/9822cccde4ca39d8066024c09a7349.png)
[graph theory brush question-5] Li Kou 1971 Find out if there is a path in the graph

Unity general steps for creating a hyper realistic 3D scene

SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions

Leetcode XOR operation

Operation of numpy array

Don't bother tensorflow learning notes (10-12) -- Constructing a simple neural network and its visualization
![[numerical prediction case] (3) LSTM time series electricity quantity prediction, with tensorflow complete code attached](/img/73/ba9fb872aa279405204c411c18f348.png)
[numerical prediction case] (3) LSTM time series electricity quantity prediction, with tensorflow complete code attached
随机推荐
R语言使用caret包的preProcess函数进行数据预处理:对所有的数据列进行BoxCox变换处理(将非正态分布数据列转换为正态分布数据、不可以处理负数)、设置method参数为BoxCox
STM32 Basics
Introduction to link database function of cadence OrCAD capture CIS replacement components, graphic tutorial and video demonstration
Mysql database - single table query (I)
如何做产品创新?——产品创新方法论探索一
selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT
The flinkcdc reports an error: but this is no longer available on the server
SQL Server Connectors By Thread Pool | DTSQLServerTP 插件使用说明
Mysql database - single table query (II)
An error is reported when sqoop imports data from Mysql to HDFS: sqlexception in nextkeyvalue
Unity 模型整体更改材质
Alicloud: could not connect to SMTP host: SMTP 163.com, port: 25
JDBC tool class jdbcfiledateutil uploads files and date format conversion, including the latest, simplest and easiest way to upload single files and multiple files
SRS deployment
论文写作 19: 会议论文与期刊论文的区别
Still using listview? Use animatedlist to make list elements move
R language uses econocrats package to create microeconomic or macroeconomic map, visualize indifference function indifference curve, customize calculation intersection, and customize the parameters of
An error is reported in the initialization metadata of the dolphin scheduler -- it turns out that there is a special symbol in the password. "$“
Why does ES6 need to introduce map when JS already has object type
使用 WPAD/PAC 和 JScript在win11中进行远程代码执行