传送门

https://www.cnblogs.com/violet-acmer/p/10163375.html

 

题解:

  这道题有点意思,有点数学的味道。

  根据定义“a”可得这求得是lcm(a,b) / a。

  转换一下:

  易知 gcd(a,b)= (a*b) / lcm(a,b) <=> lcm(a,b) = (a*b) / gcd(a,b)

  那么 lcm(a,b) / a <=> b / gcd(a,b)

  而gcd(a,b)不就是b的约数吗?

  因为 a 取的最大值为 1018  ;

  而 b 的最大值才为 1010 ;

  所以这道题直接转化为求 b 的约数个数了.

AC代码:

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<cmath>
 5 #include<algorithm>
 6 using namespace std;
 7 #define ll __int64
 8 
 9 ll b;
10 int Prime()
11 {
12     int res=2;
13     int x=sqrt(b);
14     for(int i=2;i <= x;++i)
15     {
16         if(b%i != 0)
17             continue;
18         res++;
19         if(b/i != i)
20             res++;
21     }
22     return (b == 1 ? 1:res);
23 }
24 int main()
25 {
26     scanf("%I64d",&b);
27     printf("%d\n",Prime());
28     return 0;
29 }
View Code

相关文章:

  • 2021-10-18
  • 2021-08-05
  • 2021-09-03
  • 2021-11-29
  • 2021-12-14
  • 2021-06-29
  • 2021-08-15
  • 2021-08-08
猜你喜欢
  • 2022-12-23
  • 2021-05-19
  • 2021-08-04
  • 2022-12-23
  • 2021-09-12
  • 2021-11-12
  • 2021-10-28
相关资源
相似解决方案