Luo Gu P5150 solution to a problem

Face questions

Since n-LCM = (A, B) = n-LCM (A, B) n- = L C m ( A , B ), can be drawn:

  • and prime factors are n prime factors
  • For each prime factor of x , the n number of the Y , then in the a and 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); 
}

 

Guess you like

Origin www.cnblogs.com/kamimxr/p/11274540.html