ABC284D Happy New Year 2023 题解

ABC284D

题意:

给定一个正整数 $N$,保证 $N = p^2 q$ 且 $p$,$q$ 均为质数。

挺简单的一道题。

因为 $N\leqslant 9\times 10^{18}$,则 $\min(p,q)\leqslant 3\times 10^6$。

直接枚举 $\min(p,q)$ 即可。

时间复杂度:$\mathcal{O}(T\sqrt[3]{n})$

评测记录

因为 $p,q$ 都是质数,便有第二种解法。

先筛出 $1\sim \sqrt[3]{n}$ 中的质数,然后枚举即可。

$3\times 10^6$ 内约有 $2\times 10^5$ 个质数,可过。

时间复杂度:$\mathcal{O}(2\times 10^5\times T)$

评测记录

posted @ 2023-01-11 22:30  Pengzt  阅读(3)  评论(0编辑  收藏  举报  来源