博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 4344
阅读量:4516 次
发布时间:2019-06-08

本文共 1509 字,大约阅读时间需要 5 分钟。

其实不过是大整数分解。。。

注意两点:注意L 不能==N

但是,N却可以是素数。。。囧

#include 
#include
#include
#include
#define LL __int64#define MAX 1LL<<61#define Times 8#define N 501#define C 101using namespace std;LL cop[N];int ct;bool cmp(LL a,LL b){ if(a
>=1; a=(a<<1)%m; } return ret;}LL quick(LL a,LL b,LL m){ LL ans=1; a%=m; while(b){ if(b&1){ ans=multi(ans,a,m); b--; } b/=2; a=multi(a,a,m); } return ans;}bool Witness(LL a,LL n){ LL m=n-1; int j=0; while(!(m&1)){ j++; m>>=1; } LL x=quick(a,m,n); if(x==1||x==n-1) return false; while(j--){ x=multi(x,x,n); if(x==n-1) return false; } return true;}bool Miller_Rabin(LL n){ if(n<2) return false; if(n==2) return true; if(!(n&1)) return false; for(int i=1;i<=Times;i++){ LL a=random(n-2)+1; if(Witness(a,n)) return false; } return true;}LL Pollard_Rho(LL n,int c){ LL x,y,d,i=1,k=2; x=random(n-1)+1; y=x; while(true){ i++; x=(multi(x,x,n)+c)%n; d=gcd(y-x,n); if(d>1&&d
=n) p=Pollard_Rho(p,k--); find(p,k); find(n/p,k);}int main(){ int T; LL n; scanf("%d",&T); while(T--){ scanf("%I64d",&n); ct=0; find(n,C); sort(cop+1,cop+1+ct,cmp); if(ct==1){ printf("1 1\n"); continue; } LL cnt=0;LL tmp=0; LL ans=0; cop[0]=1; cop[++ct]=1; for(int i=1;i<=ct;i++){ if(cop[i]!=cop[i-1]){ ans+=tmp; tmp=cop[i]; cnt++; } else{ tmp*=cop[i]; } } if(ans==n) ans/=cop[1]; printf("%I64d %I64d\n",cnt-1,ans); } return 0;}

  

转载于:https://www.cnblogs.com/jie-dcai/p/4143987.html

你可能感兴趣的文章
Elliptical Arcs with SVG
查看>>
做好微博营销的技巧与步骤
查看>>
Docker从入门到实战(二)
查看>>
自定义相机
查看>>
Oracle 体系结构2 - 实例和数据库
查看>>
关于Unity中Vector2和Vector3的使用
查看>>
类与方法
查看>>
Python学习笔记(九) map、zip和filter函数
查看>>
吴裕雄 Bootstrap 前端框架开发——Bootstrap 字体图标(Glyphicons):glyphicon glyphicon-plus-sign...
查看>>
吴裕雄--天生自然 JAVASCRIPT开发学习:比较 和 逻辑运算符
查看>>
html 存放PDF文档
查看>>
setTimeout 传参
查看>>
PC客户端开发细节记录:保存GUID到VARIANT
查看>>
day5感想
查看>>
给DEDE织梦CMS添加搜索结果页显示自定义字段
查看>>
第二章 第五节 获取帮助
查看>>
分布式监控系统Zabbix-3.0.3-完整安装记录(0)
查看>>
关于源代码及其管理工具的总结
查看>>
此文对你人生会有莫大好处的,建议永久保存 2013-07-26 11:04 476人阅读 评论(0) ...
查看>>
win10 压缩包安装mysql8.0.11报错:Access denied for user 'root'@'localhost'
查看>>