#include <cstdio> #define nm n * m #define int long long inline int gcd(int a, int b) { int r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; } signed main(signed argc, char** argv) { int n, m, s = 0; scanf ("%lld%lld", &n, &m); for (int i = n; i <= m; ++i) { // if (i * i > nm) break; if (nm % i == 0 && gcd(i, nm / i) == n) { // printf ("%d %d\n", i, nm / i); ++s; } } printf ("%lld\n", s); }
洛谷AC地址:
代码如上。
全部评论
(1) 回帖