The sum of the number of divisor template _ _ about and

If N = p1 ^ c1 * p2 ^ c2 * ... * pk ^ ck
divisor number: (c1 + 1) * ( c2 + 1) * ... * (ck + 1)
about the number of and: (p1 ^ 0 + p1 ^ 1 + ... + p1 ^ c1) * ... * (pk ^ 0 + pk ^ 1 + ... + pk ^ ck)

//约数个数(a+1)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL; 
const int mod = 1e9 + 7;
int main(){
    int n,x;
    LL ans = 1;
    map<int,int> hash;
    cin >> n;
    while(n--){
        cin >> x;
        for(int i = 2;i <= x/i; ++i){
            while(x % i == 0){
                x /= i;
                hash[i] ++;
            }
        }
        if(x > 1) hash[x] ++;
    }
    for(map<int,int>::iterator i = hash.begin() ; i != hash.end() ; i++) ans = ans*(i->second + 1) % mod;
    cout << ans;
    return 0;
}
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int mod=1e9+7;

map<int,int> primes;
int main(){
    int n;
    cin>>n;

    while(n--){
        int x;
        cin>>x;

        for(int i=2;i<=x/i;i++){
            while(x%i==0){
                x/=i;
                primes[i]++;
            }
        } 
        if(x>1) primes[x]++;           //注意是x>1
    }

    ll res=1;
    for(map<int,int>::iterator prime = primes.begin() ; prime != primes.end() ; prime++){           
        int p=prime->first,a=prime->second;
        ll t=1;
        while(a--) t=(t*p+1)%mod;         //求出 p0一直加到p的k的次方 的和
        res=res*t%mod;
    }
    cout<<res<<endl;
}

//3
//2
//6
//8
//res=252
Published 12 original articles · won praise 0 · Views 118

Guess you like

Origin blog.csdn.net/qq_45244489/article/details/105073232