当前位置:网站首页>团体程序设计天梯赛-练习集 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 monitoring system deployment
- How to reset IntelliSense in vs Code- How to reset intellisense in VS Code?
- 促进OKR落地的工作总结该如何写?
- Basic DOS commands
- Distributed transaction management DTM: the little helper behind "buy buy buy"
- I was pressed for the draft, so let's talk about how long links can be as efficient as short links in the development of mobile terminals
- Wechat has new functions, and the test is started again
- Put a lantern on the website during the Lantern Festival
- zabbix监控系统自定义监控内容
- L1-027 rental (20 points)
猜你喜欢
墨者学院-phpMyAdmin后台文件包含分析溯源
Distributed transaction management DTM: the little helper behind "buy buy buy"
Detailed introduction to the big changes of Xcode 14
Introduction to neural network (Part 2)
博客停更声明
【Go基础】2 - Go基本语句
Oracle stored procedures and functions
University stage summary
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
弈柯莱生物冲刺科创板:年营收3.3亿 弘晖基金与淡马锡是股东
随机推荐
[go basics] 1 - go go
PCIe knowledge points -010: where to get PCIe hot plug data
1. Kalman filter - the best linear filter
神经网络入门(下)
[real case] how to deal with the failure of message consumption?
L1-022 odd even split (10 points)
Unity text superscript square representation +text judge whether the text is empty
University stage summary
Amd RX 7000 Series graphics card product line exposure: two generations of core and process mix and match
Moher college phpMyAdmin background file contains analysis traceability
Project 1 household accounting software (goal + demand description + code explanation + basic fund and revenue and expenditure details record + realization of keyboard access)
ZABBIX 5.0 monitoring client
Book list | as the technical support Party of the Winter Olympics, Alibaba cloud's technology is written in these books!
Unity-写入Word
Example analysis of C # read / write lock
Tri des fonctions de traitement de texte dans MySQL, recherche rapide préférée
Advanced MySQL: Basics (5-8 Lectures)
How to use C language code to realize the addition and subtraction of complex numbers and output structure
Introduction to sap commerce cloud B2B organization function
MySQL 数据库 - 函数 约束 多表查询 事务