>>48
前スレでもGMPだって紹介されてたし
https://gmplib.org/manual/Perfect-Square-Algorithm.html
https://gmplib.org/repo/gmp/file/tip/mpn/generic/perfsqr.c

実際に使われる法はビルド時生成(https://gmplib.org/repo/gmp/file/tip/gen-psqr.c)だけど大抵の32/64bitシステムの場合は書いてある通り