注意: 判断1000000007这种只有一个质数特别大的情况

#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
bool check(int x)
{for(int i=2;i<=x/i;i++) if(x%i==0) return false;return true;
}
int main(void)
{int n; cin>>n;cout<<n<<"=";if(check(n)) {cout<<n;return 0;}for(int i=2;i<=n;i++) while(n%i==0) n/=i,mp[i]++;string ans;for(auto i=mp.begin();i!=mp.end();i++){if(i->second>1) ans+=to_string(i->first)+"^"+to_string(i->second)+"*";else ans+=to_string(i->first)+"*";}cout<<ans.substr(0,ans.size()-1);return 0;
}

1059 Prime Factors (25 分)【难度: 一般 / 知识点: 分解质因子 】相关推荐

  1. 【题目分析】1059 Prime Factors (25 分)

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Given any positive integer N, you are supposed to find all of its ...

  2. 1059. Prime Factors (25)

    题目如下: Given any positive integer N, you are supposed to find all of its prime factors, and write the ...

  3. PAT甲题题解-1059. Prime Factors (25)-素数筛选法

    用素数筛选法即可. 范围long int,其实大小范围和int一样,一开始以为是指long long,想这就麻烦了该怎么弄. 而现在其实就是int的范围,那难度档次就不一样了,瞬间变成水题一枚,因为i ...

  4. 1059. Prime Factors (25)--taste

    点击打开链接 注意: 1.对于输入为1的情况要特判 2.factor在int范围内开到10就足够 3.sqrt是范围,由于n后面被修改故范围要单写,且sqrt是double int sqr=sqrt( ...

  5. 1059 Prime Factors(25 分)(cj)

    1059 Prime Factors(25 分) Given any positive integer N, you are supposed to find all of its prime fac ...

  6. 1059 Prime Factors

    1059 Prime Factors (25 分) Given any positive integer N, you are supposed to find all of its prime fa ...

  7. PAT 1059 Prime Factors[难]

    1059 Prime Factors (25 分) Given any positive integer N, you are supposed to find all of its prime fa ...

  8. PAT甲级1059 Prime Factors :[C++题解]分解质因子

    文章目录 题目分析 题目链接 题目分析 暴力求质因数 下面i就是质因子,s是质因子i的阶数. 暴力的时间复杂度O(n),会超时 void divide(int n){for(int i=2;i< ...

  9. 1059 Prime Factors(25 分)

    Given any positive integer N, you are supposed to find all of its prime factors, and write them in t ...

最新文章

  1. windows 下xampp集成环境安装mongodb扩展
  2. Hyper-V 2016 系列教程25 配置NFS 存储服务器
  3. Openssl:构建CA的过程并实现web服务基于https访问的网络架构
  4. easyui messager 消息框 对话框
  5. 聚类算法:Hierarchical Clustering层次聚类
  6. ufs2.0测试软件,【玩机组教程】让你的一加3/3T的ufs2.0闪存速度焕发新生
  7. Android Studio的快捷键图文并茂
  8. 9-5:C++多态之多态和继承的经典题目以及面试中常考内容
  9. IPC--进程间通信三(共享内存)
  10. 突发!百度AI开发者大会李彦宏遭泼水 百度官方回应...
  11. Firefox和Chrome浏览器导出书签
  12. java 当前时间 15分钟_怎么用java 获取15分钟以前的时间
  13. 惊!使用nw.js将vue项目打包为可在xp系统运行的桌面程序
  14. 网站地图是什么,怎么制作和查看网站的地图呢?
  15. 公司邮箱登录入口哪个方便,邮箱移动办公哪个最好用?
  16. 冲水步骤(智能马桶开发记录)
  17. python应用开发实战第一章 兽人之袭0.0.1
  18. Qt QPlainTextEdit和QTextEdit区别
  19. mysql统计枚举值
  20. pygame实现动态小鸟飞行 + 打包发布

热门文章

  1. 角点检测——发现图像的特征
  2. docker 的mysql镜像使用手册 官网原文 日期2017-05-25
  3. shell对文本进行操作命令
  4. Android 把第三方jar 打进java包
  5. eclipse 出现 jar包找不到 问题记录
  6. Flexible 弹性盒子模型之CSS align-self 属性
  7. python 2.7 简单模拟登陆网站
  8. ESP32 各种时钟参数值设置
  9. 如何用jlink+jflash烧写stm32f103CB的option bytes 和程序
  10. 蓝牙BLE LINK LAYER剖析(二) -- PDU