当前位置:网站首页>团体程序设计天梯赛-练习集 L1-006 连续因子
团体程序设计天梯赛-练习集 L1-006 连续因子
2022-07-04 07:53:00 【Cod_ing】
特点:稍微改进了这位同志的代码
#include<iostream>
#include<vector>
#include<cmath>
typedef long long ll;
using namespace std;
int main() {
int n;
vector<int> ans;
vector<int> temp_;
cin >> n;
int lim = sqrt(n); //输入数的因子不会超过它的根
for (int i = 2; i <= lim; i++) {
ll temp = 1;
for (int j = 0; j < 12; j++) {
//13的阶乘超过了int的最大值(2^31),因此长度最大不会超过12
temp *= (i + j);
if (temp > n)
break;
if (n % temp == 0) {
temp_.push_back(i + j);
}
else
break;
}
if (temp_.size() > ans.size()) {
ans.assign(temp_.begin(), temp_.end());
}
temp_.clear();
}
if (ans.empty()) {
//特殊判断防止造成段超越
cout << 1 << endl << n;
return 0;
}
cout << ans.size() << endl;
if (ans.size() == 1)
cout << ans[0];
else {
for (int i = 0; i < ans.size() - 1; i++)
cout << ans[i] << "*";
cout << ans[ans.size() - 1];
}
return 0;
}
边栏推荐
- What are the work contents of operation and maintenance engineers? Can you list it in detail?
- Jianmu continuous integration platform v2.2.2 release
- Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
- Common components of flask
- 谷歌官方回应:我们没有放弃TensorFlow,未来与JAX并肩发展
- 21个战略性目标实例,推动你的公司快速发展
- User login function: simple but difficult
- Moher College webmin unauthenticated remote code execution
- [gurobi] establishment of simple model
- 神经网络入门(下)
猜你喜欢
MySQL中的文本处理函数整理,收藏速查
Introduction to neural network (Part 2)
论文学习——基于极值点特征的时间序列相似性查询方法
Introduction to sap commerce cloud B2B organization function
System architecture design of circle of friends
PCIe knowledge points -010: where to get PCIe hot plug data
1、卡尔曼滤波-最佳的线性滤波器
ZABBIX monitoring system custom monitoring content
墨者学院-PHPMailer远程命令执行漏洞溯源
Zephyr Learning note 2, Scheduling
随机推荐
Difference between static method and non static method (advantages / disadvantages)
Sqli labs download, installation and reset of SQL injection test tool one of the solutions to the database error (# 0{main}throw in d:\software\phpstudy_pro\www\sqli labs-...)
JVM -- class loading process and runtime data area
How to improve your system architecture?
L1-024 the day after tomorrow (5 points)
Blog stop statement
Unity-写入Word
User login function: simple but difficult
深入浅出:了解时序数据库 InfluxDB
Practice (9-12 Lectures)
Activiti常見操作數據錶關系
Types of references in BibTex
【Go基础】2 - Go基本语句
MYCAT middleware installation and use
OKR vs. KPI 一次搞清楚这两大概念!
L1-026 I love gplt (5 points)
Zephyr 学习笔记1,threads
Take you to master the formatter of visual studio code
L1-028 judging prime number (10 points)
[test de performance] lire jmeter