/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 5ms 4.277 MiB
#2 Accepted 5ms 4.277 MiB
#3 Accepted 7ms 4.379 MiB
#4 Accepted 17ms 4.277 MiB
#5 Accepted 28ms 5.672 MiB
#6 Accepted 10ms 4.277 MiB
#7 Accepted 20ms 4.77 MiB
#8 Accepted 10ms 4.277 MiB
#9 Accepted 22ms 4.812 MiB
#10 Accepted 10ms 4.277 MiB
#11 Accepted 29ms 4.523 MiB

Code

#include<bits/stdc++.h>
#define endl        '\n'
#define F           first
#define S           second
#define pb          push_back
#define yes         cout<<"YES\n"
#define no          cout<<"NO\n"
#define all(x)      x.begin(),x.end()
#define allr(x)     x.rbegin(),x.rend()
#define error1(x)   cerr<<#x<<" = "<<(x)<<endl
#define error2(a,b) cerr<<"("<<#a<<", "<<#b<<") = ("<<(a)<<", "<<(b)<<")\n";
#define coutall(v)  for(auto &it: v) cout << it << " "; cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
const int mod = 1e9 +  7;

const int N = 1e6 + 10;
vector<int> spf(N); // SPF : smallest prime factor

void sieve() //=> O(n log(log(n)))
{
    for (int i = 1; i < N; i++)
    {
        spf[i] = i;
    }
    for (int i = 2; i * i < N; i++)
    {
        if (spf[i] == i)
        {
            for (int j = i * i; j < N; j += i)
            {
                if (spf[j] == j) spf[j] = i;
            }
        }
    }
}

void solve() {
    ll n, ans = 1;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        while (x != 1) {
            mp[spf[x]] += 1;
            x /= spf[x];
        }
    }
    mp[1] = 0;
    for(auto &[i, j]: mp) {
        ans *= (ll)j + 1;
        ans %= mod;
    }
    cout << ans << endl;
    return;
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    sieve(); // <===
    int tc = 1;
    // cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case " << t << ": ";
        solve();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1060 Divisor
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-20 10:38:09
Judged At
2024-05-20 10:38:09
Judged By
Score
100
Total Time
29ms
Peak Memory
5.672 MiB