当前位置:网站首页>团体程序设计天梯赛-练习集 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;
}
边栏推荐
- BUUCTF(3)
- MySQL中的文本處理函數整理,收藏速查
- Distributed transaction management DTM: the little helper behind "buy buy buy"
- Unity-写入Word
- Life planning (flag)
- Sports [running 01] a programmer's half horse challenge: preparation before running + adjustment during running + recovery after running (experience sharing)
- PCIE知识点-010:PCIE 热插拔资料从哪获取
- JVM -- class loading process and runtime data area
- Linear algebra 1.1
- Relations courantes de la fiche de données d'exploitation pour les activités
猜你喜欢
Detailed introduction to the big changes of Xcode 14
Book list | as the technical support Party of the Winter Olympics, Alibaba cloud's technology is written in these books!
谷歌官方回应:我们没有放弃TensorFlow,未来与JAX并肩发展
JVM中堆概念
Thesis learning -- time series similarity query method based on extreme point characteristics
如何用MOS管来实现电源防反接电路
Preliminary study on temporal database incluxdb 2.2
PCIe knowledge points -010: where to get PCIe hot plug data
Tri des fonctions de traitement de texte dans MySQL, recherche rapide préférée
Flask 常用组件
随机推荐
How to write a summary of the work to promote the implementation of OKR?
One of the general document service practice series
如何用MOS管来实现电源防反接电路
MySQL中的文本處理函數整理,收藏速查
Unity write word
Zephyr 学习笔记1,threads
Sports [running 01] a programmer's half horse challenge: preparation before running + adjustment during running + recovery after running (experience sharing)
[Gurobi] 简单模型的建立
[go basics] 2 - go basic sentences
Rapidjson reading and writing JSON files
[gurobi] establishment of simple model
How to get bytes containing null terminators from a string- c#
论文学习——基于极值点特征的时间序列相似性查询方法
Flask 常用组件
L1-022 odd even split (10 points)
R language ggplot2 visualization: ggplot2 visualization grouping box diagram, place the legend and title of the visualization image on the top left of the image and align them to the left, in which th
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
The text box displays the word (prompt text) by default, and the text disappears after clicking.
L1-030 one gang one (15 points)
Activiti常见操作数据表关系