反正知道了就是知道,不知道也想不到,很快

#include <cstdio>
#include <cstdlib>
#include <vector> using namespace std; inline void print_prime_k(long long p, long long k) {
printf("%lld", p);
if (k > ) {
printf("^%lld", k);
}
} int main() {
long long n, on;
scanf("%lld", &n);
on = n;
vector<long long> ps;
vector<long long> count; long long i = ;
long long last = ;
while (n > ) {
while (n % i == ) {
n = n/i;
if (i != last) {
ps.push_back(i);
count.push_back();
last = i;
}
count.back()++;
}
i++;
} int len = ps.size();
if (len > ) {
printf("%lld=", on);
print_prime_k(ps[], count[]);
} else {
printf("%lld=%lld", on, on);
}
for (int i=; i<len; i++) {
printf("*");
print_prime_k(ps[i], count[i]);
}
system("pause");
return ;
}

考虑输入是1的情况输出要为1=1

PAT 1059. Prime Factors的更多相关文章

  1. PAT 1059 Prime Factors[难]

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

  2. PAT 1059. Prime Factors (25) 质因子分解

    题目链接 http://www.patest.cn/contests/pat-a-practise/1059 Given any positive integer N, you are suppose ...

  3. PAT 甲级 1059 Prime Factors (25 分) ((新学)快速质因数分解,注意1=1)

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

  4. 1059 Prime Factors (25分)

    1059 Prime Factors (25分) 1. 题目 2. 思路 先求解出int范围内的所有素数,把输入x分别对素数表中素数取余,判断是否为0,如果为0继续除该素数知道余数不是0,遍历到sqr ...

  5. PAT 甲级 1059 Prime Factors

    https://pintia.cn/problem-sets/994805342720868352/problems/994805415005503488 Given any positive int ...

  6. PAT Advanced 1059 Prime Factors (25) [素数表的建⽴]

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

  7. 1059. Prime Factors (25)

    时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 HE, Qinming Given any positive integer N, y ...

  8. 1059 Prime Factors(25 分)

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

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

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

随机推荐

  1. 微服务框架Spring Cloud介绍 Part1: 使用事件和消息队列实现分布式事务

    http://skaka.me/blog/2016/04/21/springcloud1/ 不同于单一架构应用(Monolith), 分布式环境下, 进行事务操作将变得困难, 因为分布式环境通常会有多 ...

  2. js去重方法

    function remove(array){ var obj={}; newarray=[]; for(var i in array){ console.log(i); var arg=array[ ...

  3. Flink学习笔记:Connectors之kafka

    本文为<Flink大数据项目实战>学习笔记,想通过视频系统学习Flink这个最火爆的大数据计算框架的同学,推荐学习课程: Flink大数据项目实战:http://t.cn/EJtKhaz ...

  4. SDUT OJ 效率至上(线段树)

    效率至上 Time Limit: 5000 ms Memory Limit: 65536 KiB Submit Statistic Problem Description 题意很简单,给出一个数目为n ...

  5. 运用CSS高斯模糊添加图片加载效果

    <!DOCTYPE html> <html> <head> <title>大图片加载从模糊到清晰</title> </head> ...

  6. XMLHttpRequest 与 Ajax 概要

    关于XMLHttpRequest 开发者使用XMLHttpRequest对象与服务端进行交互(发送http请求.接受返回数据等),可以在不打断用户下一步操作的情况下刷新局部页面.XMLHttpRequ ...

  7. shared_ptr智能指针

    来自博客:https://www.cnblogs.com/lzpong/p/6188034.html 多线程程序经常会遇到在某个线程A创建了一个对象,这个对象需要在线程B使用, 在没有shared_p ...

  8. libcaffe.so.1.0.0: cannot open shared object file: No such file or directory 运行时报错

    caffe安装好后lib没有配置到/usr/lib或/usr/local/lib中,需手动配置: sudo vim ~/.bashrc export LD_LIBRARY_PATH=your_path ...

  9. VS2013过期激活

    然后点击"更改我的产品许可证",输入密钥  : BWG7X-J98B3-W34RT-33B3R-JVYW9 即可注册成功...

  10. python怎样在一行中捕获多个异常

    所属网站分类: python基础 > 异常处理 作者:浮沉 链接:http://www.pythonheidong.com/blog/article/71/ 来源:python黑洞网,专注pyt ...