Untitled

mail@pastecode.io avatar
unknown
plain_text
7 days ago
1.1 kB
0
Indexable
Never
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
#define MOD 1000000007
using namespace std;

void sieve(ll n, bool prime[])
{
    for (ll i=1; i<=n; i++)
        prime[i] = 1;
    prime[1] = 0;
    for (ll i=2; i*i<=n; i++)
    {
        if (prime[i])
        {
            for (ll j=i*i; j<=n; j += i)
                prime[j] = 0;
        }
    }
}

int expFactor(ll n, ll p)
{
    ll x = p;
    ll exponent = 0;
    while ((n/x) > 0)
    {
        exponent += n/x;
        x *= p;
    }
    return exponent;
}

ll countFactors(int n)
{
    ll ans = 1;
    bool prime[n+1];
    sieve(n, prime);
    for (ll p=1; p<=n; p++)
    {
        if (prime[p]==1){
            ans *= (2*expFactor(n, p) + 1)%MOD;
            ans%=MOD;
        }
    }

    return ans;
}

int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        cout<<countFactors(n)<<endl;
    }
    return 0;
}
Leave a Comment