当前位置:网站首页>团体程序设计天梯赛-练习集 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;
}
边栏推荐
- Zephyr 学习笔记2,Scheduling
- Zephyr 學習筆記2,Scheduling
- How to send mail with Jianmu Ci
- Unity text superscript square representation +text judge whether the text is empty
- string. Format without decimal places will generate unexpected rounding - C #
- L1-023 output gplt (20 points)
- 真空介电常数和真空磁导率究竟是由什么决定的?为何会存在这两个物理量?
- 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
- MySQL 数据库 - 函数 约束 多表查询 事务
- zabbix监控系统自定义监控内容
猜你喜欢

【Go基础】2 - Go基本语句

Zephyr study notes 2, scheduling

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

Oceanbase is the leader in the magic quadrant of China's database in 2021

Oracle-存储过程与函数

MySQL中的文本处理函数整理,收藏速查

zabbix监控系统自定义监控内容
![[performance test] read JMeter](/img/c9/25a0df681c7ecb4a0a737259c882b3.png)
[performance test] read JMeter

In the era of low code development, is it still needed?
![[network security] what is emergency response? What indicators should you pay attention to in emergency response?](/img/2e/96da79d82ae2c49a3a0ab9909467ac.jpg)
[network security] what is emergency response? What indicators should you pay attention to in emergency response?
随机推荐
Leetcode (215) -- the kth largest element in the array
时序数据库 InfluxDB 2.2 初探
How to reset IntelliSense in vs Code- How to reset intellisense in VS Code?
Unity write word
Ecole bio rushes to the scientific innovation board: the annual revenue is 330million. Honghui fund and Temasek are shareholders
线性代数1.1
Oracle-存储过程与函数
Linear algebra 1.1
User login function: simple but difficult
Chrome is set to pure black
L1-023 output gplt (20 points)
Parallel shift does not provide any acceleration - C #
Basic DOS commands
1. Getting started with QT
Introduction to sap commerce cloud B2B organization function
How to get bytes containing null terminators from a string- c#
Project 1 household accounting software (goal + demand description + code explanation + basic fund and revenue and expenditure details record + realization of keyboard access)
21 examples of strategic goals to promote the rapid development of your company
zabbix监控系统自定义监控内容
Rapidjson reading and writing JSON files