当前位置:网站首页>团体程序设计天梯赛-练习集 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;
}
边栏推荐
- Leetcode 23. 合并K个升序链表
- 1、卡尔曼滤波-最佳的线性滤波器
- 运动【跑步 01】一个程序员的半马挑战:跑前准备+跑中调整+跑后恢复(经验分享)
- L1-025 positive integer a+b (15 points)
- L1-030 one gang one (15 points)
- [network security] what is emergency response? What indicators should you pay attention to in emergency response?
- PCIE知识点-010:PCIE 热插拔资料从哪获取
- 谷歌官方回应:我们没有放弃TensorFlow,未来与JAX并肩发展
- Distributed transaction management DTM: the little helper behind "buy buy buy"
- 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)
猜你喜欢

The idea of implementing charts chart view in all swiftui versions (1.0-4.0) was born

Go learning notes - constants

Introduction to neural network (Part 2)

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

Zephyr study notes 2, scheduling

Moher college phpMyAdmin background file contains analysis traceability

JVM中堆概念

神经网络入门(下)

University stage summary

Zephyr Learning note 2, Scheduling
随机推荐
How to improve your system architecture?
【性能测试】一文读懂Jmeter
Take you to master the formatter of visual studio code
Types of references in BibTex
The right way to capture assertion failures in NUnit - C #
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
Cannot click button when method is running - C #
论文学习——基于极值点特征的时间序列相似性查询方法
[C language] open the door of C
C # implements a queue in which everything can be sorted
ZABBIX 5.0 monitoring client
Distributed transaction management DTM: the little helper behind "buy buy buy"
Wechat has new functions, and the test is started again
1. Getting started with QT
线性代数1.1
Moher College phpmailer remote command execution vulnerability tracing
【Go基础】1 - Go Go Go
What determines vacuum permittivity and vacuum permeability? Why do these two physical quantities exist?
Linear algebra 1.1
ZABBIX monitoring system deployment