#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<ctime>
#include<cmath>
#include<iostream>
using namespace std; #define LL long long
LL n;
#define maxs 80
LL fac[maxs],num[maxs],lf=;
LL mul(LL a,LL b,LL p)
{
LL tmp=a,ans=;
while (b) {if (b&) ans=(ans+tmp)%p;tmp=(tmp+tmp)%p;b>>=;}
return ans;
}
LL random(LL x) {return (LL)((double)rand()/RAND_MAX*(x-)+0.5);}
LL f(LL x,LL c,LL p) {return (mul(x,x,p)+c)%p;}
LL gcd(LL a,LL b) {if (a<b) return gcd(b,a);return b?gcd(b,a%b):a;}
LL play(LL x,LL c)
{
LL a=random(x-)+,b=f(a,c,x),i=,k=;
if (a==b) return x;
while (++i)
{
LL sig=gcd(fabs(a-b),x);
if (sig> && sig<x) return sig;
b=f(b,c,x);
if (a==b) return x;
if (i==k) a=b,k<<=;
}
}
LL pow_mod(LL a,LL b,LL p)
{
LL tmp=a,ans=;
while (b) {if (b&) ans=mul(ans,tmp,p);tmp=mul(tmp,tmp,p);b>>=;}
return ans;
}
bool is_prime(LL x)
{
LL num=x-,k=;while (!(num&)) num>>=,k++;
for (int i=;i<=;i++)
{
LL t=random(x-)+,jud=pow_mod(t,num,x),now=jud;
for (int j=;j<=k;j++)
{
jud=mul(jud,jud,x);
if (jud== && now!= && now!=x-) return ;
now=jud;
}
if (jud!=) return ;
}
return ;
}
void rho(LL x,LL c)
{
if (x==) return;
if (is_prime(x)) {fac[++lf]=x;return;}
LL p=x,tmp=c;
while (p==x) p=play(x,tmp--);
rho(p,c);rho(x/p,c);
}
int main()
{
srand(time(NULL));
scanf("%lld",&n);
memset(fac,,sizeof(fac));
rho(n,);sort(fac+,fac++lf);num[]=;LL nlf=;
for (int i=;i<=lf;i++)
if (fac[i-]==fac[i]) num[nlf]++;
else num[++nlf]=,fac[nlf]=fac[i];
lf=nlf;
for (int i=;i<lf;i++) printf("%lld^%lld*",fac[i],num[i]);printf("%lld^%lld\n",fac[lf],num[lf]);
return ;
}

最新文章

  1. C语言中如何判断文件是否存在
  2. hibernate中validate的使用(转)
  3. 介绍开源的.net通信框架NetworkComms框架之四 消息边界
  4. COM是一个更好的C++
  5. Cassandra——类似levelDB的基于p2p架构的分布式NOSQL数据库
  6. 【MVC】自定义ASP.NET MVC Html辅助方法
  7. 读取本地excel发短信
  8. win7系统无线 VirtualBox rehat 32位linux 下 host-only模式相互通信及上网 配置
  9. 选择一个利于SEO的空间
  10. Unity3D环境GLSL shaders书面 — 固体参数
  11. Spring Data JPA: 实现自定义Repository
  12. Android获取状态栏高度、标题栏高度、编辑区域高度
  13. visual studio no editoroptiondefinition export found for the given option nam
  14. JS合并两个数组的方法
  15. Jenkins忘记admin密码处理方法
  16. xampp 使用过程中刚遇到的问题记录
  17. Web项目发布步骤总结
  18. Shell逻辑语句
  19. BLE获取iphone mac地址的方法--【原创】
  20. java-信息安全(十六)-双向认证

热门文章

  1. html5新增的主题结构元素
  2. CF962D Merge Equals
  3. checkbox:全选、全不选、单选(慕课网题目)
  4. 【学习笔记】深入理解js原型和闭包(13)——【作用域】和【上下文环境】
  5. 【学习笔记】深入理解js原型和闭包(6)——继承
  6. gp服务输出的结果文件输出到绝对路径
  7. java.lang.NoSuchMethodError: org.hibernate.cfg.Environment.verifyProperties
  8. 洛谷 P3038 [USACO11DEC]牧草种植Grass Planting
  9. Python3简明教程(十一)—— 类
  10. Chomp游戏(必胜策略分析)