当前位置:网站首页>PAT甲级 1059 Prime Factors
PAT甲级 1059 Prime Factors
2022-08-08 00:53:00 【九是否非随机的称呼】
#include<iostream>
#include<vector>
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
bool isprime(long int x, long int y){
if(x==2||x==3||x==5||x==7||x==11) {
v.push_back(x);
return true;
}
for(long int i = 2; i <= y; i++){
if(x%i==0){
isprime(i, sqrt(i) + 3);
isprime(x/i, sqrt(x/i) + 3);
return false;
}
}
v.push_back(x);
return true;
}
int main(void){
long int i, j, x, y, cnt;
cin>>x;
y = sqrt(x) + 3;
isprime(x, y);
sort(v.begin(), v.end());
vector<int> v0, exp;
v0.push_back(v[0]);
y = 1;
cnt = 0;
for(i = 1; i < v.size(); i++){
if(v0[cnt]==v[i]){
y++;
continue;
}else{
v0.push_back(v[i]);
exp.push_back(y);
y = 1;
cnt++;
}
}
if(exp.size()!=v0.size()) exp.push_back(y);
cout<<x<<"=";
for(i = 0; i<v0.size(); i++){
cout<<v0[i];
if(exp[i]>1){
cout<<"^"<<exp[i];
}
if(i!=v0.size()-1) cout<<"*";
}
return 0;
}边栏推荐
- [CISCN 2019 Preliminary Competition] Love Math
- Let’s talk about the anti-reverse circuit in combination with the actual situation (summary of the anti-reverse circuit)
- MySQL index
- 高数_证明_柯西中值定理
- 解决:ERROR: Cannot uninstall ‘certifi‘. It is a distutils installed project and thus we cannot accurat
- 空间地理数据可视化之 leaflet 包及其拓展
- Is it safe and reliable to open a mobile stock account?
- 【PHP库】phpseclib - sftp远程文件操作
- 【HDLBits 刷题 6】Circuits(2)Sequential Logic---Latches and Filp Flops
- MD5加密工具类
猜你喜欢
随机推荐
陈强教授《机器学习及R应用》课程第十一章作业
喜讯|宏时数据获得CMMI3级认证!欢迎了解自研统一运维监控平台!
陈强教授《机器学习及R应用》课程 第六章作业
BOSS直聘再爆情色招聘丑闻,面试官行为不堪入目
第三章 矩阵压缩
激光雷达战场越来越激烈了
家乡的黄桃
High performance cloud storage MinIO combat - native data object
阿包的夜宵
adb命令logcat抓取日志
倒水问题(暑假每日一题 17)
陈强教授《机器学习及R应用》课程 第十章作业
并行化-你的高并发大杀器
5、基于EasyExcel的导入导出
Analysis of Qiangwang Cup 2022 pwn competition questions - yakacmp
【HDLBits 刷题 6】Circuits(2)Sequential Logic---Latches and Filp Flops
Modify the jdbc data source password through the configuration file in the weblogic background
kaggle小白必看:小白常见的2个错误解决方案
JS中常用的数组方法(补充)
torch.utils.data of PyTorch source code interpretation: the whole process of parsing data processing (very good, one article is enough)
https://github.com/ZouJiu1/PAT








