/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 8ms 1.188 MiB
#2 Accepted 8ms 1.094 MiB
#3 Accepted 11ms 1.188 MiB
#4 Accepted 31ms 1.285 MiB
#5 Time Exceeded ≥1093ms ≥1.852 MiB
#6 Accepted 89ms 1.281 MiB
#7 Accepted 215ms 1.375 MiB
#8 Time Exceeded ≥1088ms ≥1.281 MiB

Code

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
using namespace std;

const int N = 1e6 + 10;
vector<bool> yo(N, true);
vector<int> primes;

void sieve() {
  yo[0] = yo[1] = false;
  for (int i = 2; i * i < N; i++) {
    if (yo[i]) {
      for (int j = i * i; j < N; j += i) {
        yo[j] = false;
      }
    }
  }
  primes.push_back(2);
  for (int i = 3; i < N; i += 2) {
    if (yo[i]) {
      primes.push_back(i);
    }
  }
}
bool isprime(int x) { return yo[x]; }

void solve(int cs) {
  sieve();
  map<int, int> cnt;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (isprime(x)) {
      cnt[x] += 1;
    } else {
      for (auto &p : primes) {
        if (p > x)
          break;
        while (x % p == 0) {
          x /= p;
          cnt[p] += 1;
        }
      }
      if (x > 1) {
        cnt[x] += 1;
      }
    }
  }
  int res = 1;
  const int mod = 1e9 + 7;
  for (auto &[_, cc] : cnt) {
    res = res * 1LL * (cc + 1) % mod;
  }
  cout << res << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc = 1;
  // cin >> tc;
  for (int cs = 1; cs <= tc; cs++) {
    solve(cs);
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1060 Divisor
Language
C++20 (G++ 13.2.0)
Submit At
2024-07-10 13:32:59
Judged At
2024-11-11 03:28:15
Judged By
Score
50
Total Time
≥1093ms
Peak Memory
≥1.852 MiB