题目

给定\(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. 项目实战:Qt+OSG三维2D文字实时效果查看工具

    需求   OSG三维中2D文字的基本属性较多,方便实时查看效果,并出对应文本代码.   Demo      工具下载地址   CSDN免积分下载地址:https://download.csdn.net ...

  2. .NET周刊【2月第3期 2024-02-25】

    国内文章 4.1k Star!全面的C#/.NET/.NET Core学习.工作.面试指南 https://www.cnblogs.com/Can-daydayup/p/18027117 DotNet ...

  3. 双层循环练习,pass_break_continue,和for循环---day06

    1.双层循环练习 2.pass_break_continue pass:在代码块中无代码可写时,可用pass占位 break:终止当前循环,只能应用在循环里 continue:跳过当前循环,从下一次开 ...

  4. deque双端队列

    # 支持从任意一端增加和删除元素 d = collections.deque() d.extend('abcdefg') d.append('h') d.extendleft(range(6)) # ...

  5. Navicat 12连接mysql8.x报错2059 - authentication plugin 'caching_sha2_password' 解决办法

    // %表示远程连接允许所有ip,如果只是连接本地,将%改为localhost即可 ALTER USER 'root'@'%' IDENTIFIED BY '你自己的mysql的密码' PASSWOR ...

  6. ZYNQ SD卡 CDn管脚的作用

    ## 什么 是CDn? card detect, active low,用于指示当前SD卡是否插入,主机通过检测CD脚的状态来识别当前SD卡的状态. CD可以连接到MIO或者EMIO的任意空闲管脚,通 ...

  7. The OCaml Language Cheatsheets

    The OCaml Language Cheatsheets OCaml v.4.08.1 Syntax Implementations are in .ml files, interfaces ar ...

  8. JAVA微服务分布式事务的几种实现方式

    基础理论 CAP理论 一致性(Consistency) :在分布式系统中所有的数据备份,在同一时刻都保持一致状态,如无法保证状态一致,直接返回错误: 可用性(Availability):在集群中一部分 ...

  9. 从0开始入门智能知识库和星火大模型,打造AI客服。

    介绍FastWiki FastWiki是一个高性能.基于最新技术栈的知识库系统,旨在为大规模信息检索和智能搜索提供解决方案.它采用微软Semantic Kernel进行深度学习和自然语言处理,在后端使 ...

  10. Java 常用类 String类与其他结构之间的转换-----String 与 char[]之间的转换

    1 /* 2 String 与 char[]之间的转换 3 4 String----> char[]:调用String的toCharArray() 5 char[] ---->String ...