当前位置:网站首页>团体程序设计天梯赛-练习集 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;
}
边栏推荐
- zabbix监控系统部署
- [Gurobi] 简单模型的建立
- 论文学习——基于极值点特征的时间序列相似性查询方法
- L1-026 I love gplt (5 points)
- Blog stop statement
- Introduction to sap commerce cloud B2B organization function
- L1-021 important words three times (5 points)
- OKR vs. KPI figure out these two concepts at once!
- 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-...)
- Text processing function sorting in mysql, quick search of collection
猜你喜欢

神经网络入门(下)

zabbix 5.0监控客户端

BUUCTF(4)

Ecole bio rushes to the scientific innovation board: the annual revenue is 330million. Honghui fund and Temasek are shareholders

Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool

运动【跑步 01】一个程序员的半马挑战:跑前准备+跑中调整+跑后恢复(经验分享)

谷歌官方回应:我们没有放弃TensorFlow,未来与JAX并肩发展

This article is enough for learning advanced mysql

Unity opens the explorer from the inspector interface, selects and records the file path

Oracle stored procedures and functions
随机推荐
Zephyr Learning note 2, Scheduling
真空介电常数和真空磁导率究竟是由什么决定的?为何会存在这两个物理量?
R language uses cforest function in Party package to build random forest based on conditional inference trees, uses varimp function to check feature importance, and uses table function to calculate co
Docker install MySQL
Used on windows Bat file startup project
猜数字游戏
How to send mail with Jianmu Ci
Oracle-存储过程与函数
Rapidjson reading and writing JSON files
1. Kalman filter - the best linear filter
Activiti常見操作數據錶關系
The frost peel off the purple dragon scale, and the xiariba people will talk about database SQL optimization and the principle of indexing (primary / secondary / clustered / non clustered)
[network security] what is emergency response? What indicators should you pay attention to in emergency response?
It's healthy to drink medicinal wine like this. Are you drinking it right
zabbix 5.0监控客户端
In the era of low code development, is it still needed?
ZABBIX monitoring system deployment
Practice (9-12 Lectures)
JVM -- class loading process and runtime data area
L1-022 odd even split (10 points)