1096. Consecutive Factors 解析
来源:互联网 发布:红蜘蛛教学软件破解 编辑:程序博客网 时间:2024/06/05 16:29
求连续的分解因子。
从2开始,然后整除,能整除,就不断的自增去看,最多能多长。
#include <iostream>#include <vector>#include <cmath>using namespace std;int n;vector <int> Ans;int main() {cin >> n;int maxFactor = sqrt(n);int MaxCount = 0;int MaxPos = n;for (int i = 2; i <= maxFactor; i++) {int t_n = n;int p = i;while (t_n % p == 0) {t_n /= p;p++;}if (p - i > MaxCount) {MaxCount = p - i;MaxPos = i;}}if (MaxCount == 0) {cout << 1 << endl;cout << n << endl;return 0;}cout << MaxCount << endl;cout << MaxPos++;for (int i = 0; i < MaxCount -1; i++) {cout << "*" << MaxPos++;}cout << endl;return 0;}
0 0
- 1096. Consecutive Factors 解析
- PAT 1096. Consecutive Factors
- 1096.Consecutive Factors
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 1096. Consecutive Factors (20)
- 去掉对话框 dialog 背景颜色 使弹出状态的 背景统一!!!
- NYOJ133子序列(坐标离散化)
- 大数据量下高并发同步的讲解
- C#实现获取枚举的描述
- 获取任意一个时间的下一天的时间
- 1096. Consecutive Factors 解析
- 设计一个脚本,根据关键字提取整段话中关键字所在的句子
- Android 百分比布局库(percent-support-lib) 解析与扩展
- jQuery 1 基础
- Mybatis 框架使用的最核心内容及mapper.xml标签使用
- SSM框架——使用MyBatis Generator自动创建代码
- Aggreagation 日常使用语句汇总(持续更新)
- 利用HttpURLConnection实现远程下载文件
- Spring注解配置Mongo及基本CRUD操作简介