题目

给定\(m\)个数\(a_i\),令\(n=\prod_{i=1}^m a_i\),

问有多少个大于1的正整数\(d\)满足\(d^{\max k}|n\)

并输出\(\max k\),\(m\leq 600,a_i\leq 10^{18}\)


分析

将\(a_i\)质因数分解,\(n\)的指数累加,那么就可以使\(n\)质因数分解,

若有\(p\)个质数使得\(p^{\max k}|n\),\(d\)的个数为\(2^p-1\),

由于\(p\leq 600\),所以要高精度乘法


代码

#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <map>
#define rr register
using namespace std;
const double ha=pow(11.0,19/17.0);
const int prime[8]={2,61,97,7,13,17,23,29},MOD=1000000000;
typedef long long lll; lll x,n,tot,mx,ans,p[41],dig[211];
map<lll,int>uk; map<lll,int>::iterator it;
inline lll iut(){
rr lll ans=0; rr char c=getchar();
while (!isdigit(c)) c=getchar();
while (isdigit(c)) ans=(ans<<3)+(ans<<1)+(c^48),c=getchar();
return ans;
}
inline lll mo(lll a,lll b,lll mod){return a+b>=mod?a+b-mod:a+b;}
inline lll mul(lll a,lll b,lll mod){return (a*b-(lll)((long double)a/mod*b)*mod+mod)%mod;}
inline lll gcd(lll a,lll b){return b?gcd(b,a%b):a;}
inline lll ksm(lll x,lll y,lll mod){
rr lll ans=1;
for (;y;y>>=1,x=mul(x,x,mod))
if (y&1) ans=mul(ans,x,mod);
return ans;
}
inline bool mr(lll n){
if (n==1) return 0;
for (rr int i=0;i<8;++i)
if (n==prime[i]) return 1;
for (rr int i=0;i<8;++i)
if (n%prime[i]==0) return 0;
rr lll m=n-1; rr int cnt=0;
while (!(m&1)) m>>=1,++cnt;
for (rr int i=0;i<8&&prime[i]<n;++i){
rr lll now=ksm(prime[i],m,n),ls=now;
for (rr int j=1;j<=cnt;++j){
now=mul(now,now,n);
if (now==1&&ls!=1&&ls!=n-1) return 0;
ls=now;
}
if (now!=1) return 0;
}
return 1;
}
inline lll rho(lll n,lll h){
if (!(n&1)) return 2;
if (!(n%3)) return 3;
rr lll x1=(rand()+1)%n,x2=x1,p=1;
for (rr int k=2;;k<<=1,x2=x1,p=1){
for (rr int i=1;i<=k;++i){
x1=mo(mul(x1,x1,n),h,n);
p=mul(p,x1>x2?x1-x2:x2-x1,n);
if (!(i&127)){
rr lll d=gcd(p,n);
if (d>1) return d;
}
}
rr lll d=gcd(p,n);
if (d>1) return d;
}
}
inline void dfs(lll n){
if (n==1) return;
if (mr(n)){
p[++tot]=n;
return;
}
rr lll t=n;
while (t==n) t=rho(n,rand()%(n-1)+1);
while (!(n%t)) n/=t;
dfs(t),dfs(n);
}
inline void cheng(int t){
rr lll s=0,g=0;
for (rr int i=1;i<=dig[0];++i)
s=dig[i]*t+g,g=s/MOD,dig[i]=s%MOD;
if (g) dig[++dig[0]]=g;
}
signed main(){
n=iut(),srand((unsigned)((lll)(new char)*ha));
for (rr int i=1;i<=n;++i){
tot=0,dfs(x=iut());
for (rr int i=1;i<=tot;++i){
rr int c=0;
while (x%p[i]==0) x/=p[i],++c;
uk[p[i]]+=c;
}
}
for (it=uk.begin();it!=uk.end();++it)
if (mx<it->second) mx=it->second,ans=1;
else if (mx==it->second) ++ans;
dig[dig[0]=1]=1;
for (rr int i=1;i<=ans/25;++i) cheng(33554432);
if (ans%25) cheng(1<<(ans%25));
--dig[1],printf("%lld\n",mx);
printf("%lld",dig[dig[0]]);
for (rr int i=dig[0]-1;i;--i) printf("%09lld",dig[i]);
return 0;
}

#Pollard-Rho,高精度#洛谷 3499 [POI2010]NAJ-Divine Divisor的更多相关文章

  1. 洛谷P3502 [POI2010]CHO-Hamsters感想及题解(图论+字符串+矩阵加速$dp\&Floyd$)

    洛谷P3502 [POI2010]CHO-Hamsters感想及题解(图论+字符串+矩阵加速\(dp\&Floyd\)) 标签:题解 阅读体验:https://zybuluo.com/Junl ...

  2. [洛谷P3501] [POI2010]ANT-Antisymmetry

    洛谷题目链接:[POI2010]ANT-Antisymmetry 题目描述 Byteasar studies certain strings of zeroes and ones. Let be su ...

  3. 洛谷 P3496 [POI2010]GIL-Guilds

    P3496 [POI2010]GIL-Guilds 题目描述 King Byteasar faces a serious matter. Two competing trade organisatio ...

  4. 洛谷 P3507 [POI2010]GRA-The Minima Game

    P3507 [POI2010]GRA-The Minima Game 题目描述 Alice and Bob learned the minima game, which they like very ...

  5. 洛谷 P3505 [POI2010]TEL-Teleportation

    P3505 [POI2010]TEL-Teleportation 题目描述 King Byteasar is the ruler of the whole solar system that cont ...

  6. 【字符串】【hash】【倍增】洛谷 P3502 [POI2010]CHO-Hamsters 题解

        这是一道字符串建模+图论的问题. 题目描述 Byteasar breeds hamsters. Each hamster has a unique name, consisting of lo ...

  7. 洛谷P3507 [POI2010]GRA-The Minima Game

    题目描述 Alice and Bob learned the minima game, which they like very much, recently. The rules of the ga ...

  8. [洛谷P3509][POI2010]ZAB-Frog

    题目大意:有$n$个点,每个点有一个距离(从小到大给出),从第$i$个点跳一次,会跳到距离第$i$个点第$k$远的点上(若有两个点都是第$k$远,就跳到编号小的上).问对于从每个点开始跳,跳$m$次, ...

  9. [洛谷P3512 [POI2010]PIL-Pilots]

    题目链接: 传送门走这里 题目分析: 感觉不是很难啊--不像是蓝题(AC量也不像)恶意评分? 少打了一个+1调了半天,就这样居然还能过60pts?我思路和题解第一篇高度重合是什么鬼啊,太过分了吧本来还 ...

  10. 【BZOJ2082】【POI2010】Divine divisor 假的pollard-rho

    题目大意:给你$m$个数$a_i$,定义$n=\Pi_{i=1}^{m}a_i$.将$n$分解质因数为$\Pi p_i^{k_i} $,$p_i$是质数.请输出$2^{max(k_i)}-1$,以及存 ...

随机推荐

  1. gin框架中的c.Next()/c.Abort()

    package main import ( "fmt" "github.com/gin-gonic/gin" ) func func1(c *gin.Conte ...

  2. XILINX SDK烧录FLASH报错不支持旧版hw_server

    最近频繁遇到SDK报错,说是不支持hw_server旧版本,此时打开vivado识别的时候也是一样报错,可能原因是我电脑安装了多个版本的VIVADO导致的,那么怎么解决呢? 打开任务管理器,kill ...

  3. 【Azure Developer】Go语言调用Azure SDK如何登录到中国区Azure环境

    问题描述 在 "使用 Azure SDK for Go 进行 Azure 身份验证" 文章中的 Go 示例代码进行登录Azure时,默认指向的是Globa Azure.当只修改AA ...

  4. nftables语法及例子

    先上我自己实际测试通过的例子,用例子便于在实践中学习: # 0 --- 说明 ---下面例子中的单引号目的是为了避免nftable参数中的星号.花括号.分号等符号被shell展开解释掉了,导致nft命 ...

  5. Nebula Graph 在众安保险的图实践

    本文首发于 Nebula Graph Community 公众号 互联网金融的借贷同传统信贷业务有所区别,相较于传统信贷业务,互联网金融具有响应快.数据规模大.风险高等特点.众安保险主要业务是做信用保 ...

  6. 代码随想录算法训练营第三十天| 51. N皇后 37. 解数独 总结

           卡哥建议:今天这三道题都非常难,那么这么难的题,为啥一天做三道? 因为 一刷 也不求大家能把这么难的问题解决,所以 大家一刷的时候,就了解一下题目的要求,了解一下解题思路,不求能直接写出 ...

  7. easy-window && aardio 桌面软件开发

    https://github.com/lixk/easy-window https://gitee.com/zha2/easy-window https://www.aardio.com/ 桌面软件开 ...

  8. Nginx 同时支持 http 和 https SSL 为了能有权限调取摄像头

    Nginx 同时支持 http 和 https 当然起项目的会后也分成俩 "dev": "vue-cli-service serve --port=8080", ...

  9. MFC自定义CStatusBar文字的颜色

    MFC里面的CStatusBar是没法自定义文字颜色的,需要我们自己绘制.这篇文章是在 Display colored text on Status Bar 代码的基础上进行改进的,使用起来更方便. ...

  10. 日常办公——Excel中重复打印标题的设置

    打印预览时,所在数据行或列不能显示在同一页,在打印区域之外还有内容,为了方便阅读,可使用顶端标题行重复或左端标题行重复,具体方法如下: 按顺序操作,完成后点击确定即完成操作.