Plus the number of factors and factor

// Calculation of the number of factors of a number of factors and 
#include <the iostream> 
#include <the cmath> 
#include <Map>
 the using  namespace STD;
 int pre [ 100 ]; 
Map < int , int > MP;
 int main ( ) {
     int n-; 
    CIN >> n-;
     int m = sqrt (n-+ . 1 );
     int SUM = . 1 ;
     int POS = 0 ;
     for ( int I = 2 ; I <= m; I ++ ) {
        int ans=0 ;
        if(n%i==0){
            pre[pos++]=i;
            while(n%i==0){
                ans++;
                n/=i;
                mp[i]++;
            }
            sum*=ans+1;
        }
    }
    if(n>1) 
    {
        pre[pos++]=n;
        mp[n]++;
        sum*=2;
    }

    int s=1;
    int ans=0;
    for(int i=0;i<pos;i++){
        ans=0;
        for(int j=0;j<=mp[pre[i]];j++){
            ans+=pow(pre[i],j);
            cout<<ans<<endl;
        }
        s*=ans;
    } 
    cout<<s<<endl; 
    cout<<sum<<endl;
    return 0;
} 

 

Guess you like

Origin www.cnblogs.com/Accepting/p/11366705.html