QOJ.ac

QOJ

Type: Editorial

Status: Open

Posted by: jiangly

Posted at: 2025-12-13 00:19:00

Last updated: 2025-12-13 00:19:05

Back to Problem

题解

如果 $c$ 无平方因子,则显然 $\operatorname{rad}(abc)\ge \operatorname{rad}(c)= c$,无解;否则,设 $c=p^2c'$,则令 $a=pc'$, $b=p(p-1)c'$,则 $\operatorname{rad}(abc)=\operatorname{rad}(p(p-1)c')< c$。因此,有解当且仅当 $c$ 有平方因子。

枚举不超过 $c^{\frac13}$ 的数尝试分解,如果分解后的数 $c'>1$,则要么是素数,要么是两个素数的乘积。只需判断 $c'$ 是否是完全平方数即可。

时间复杂度为每组数据 $O(c^{\frac13})$,也可以预处理 $c^{\frac13}$ 内的素数做到每组数据 $O(c^{\frac13}/\log c)$。当然也可以直接用整数分解的算法,如 Pollard-Rho。

Comments

No comments yet.