Since n-LCM = (A, B) = n-LCM (A, B) n- = L C m ( A , B ), can be drawn:
- a and b prime factors are n prime factors
- For n each prime factor of x , the n number of the Y , then x in the a and b with at least a number of the Y , the number of times the other of <= Y .
So we just put n seek times each prime factors out just fine
即 ans = (2a1 + 1) × (2a2 + 1) × ...... × (2an + 1).
#include <iostream> #include <cmath> #pragma GCC optimize(2) using namespace std; void fenjie(long long n) { long long ans=1; for(register long long i=2;i<=sqrt(n);i++) { if(n%i==0) { int cnt=0; while(n%i==0) { n/=i; cnt ++ ; } Years * = ( 2 * cnt + 1 ); } } If (n> 1 ) year * = 3 ; cout << years; } Int main () { long long n; cin >> n; fenjie (n); }