-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy path2661.cpp
35 lines (29 loc) · 957 Bytes
/
2661.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
math > number theory > prime numbers > prime factorization
difficulty: hard
date: 14/Sep/2019
problem: compute the number of divisors of n that can be written as the product of two or more distinct prime numbers (without repetition), 1 <= n <= 10^12
hint: note that the product of any combination of prime factors of a number will always be a divisor of that number
by: @brpapa
*/
#include <iostream>
#include <cmath>
#include <set>
#define ll long long
using namespace std;
set<ll> PFs;
void primeFactors(ll n) {
int sn = (int)sqrt(n)+1;
for (int i = 2; n > 1 && i <= sn; i++)
while (n % i == 0)
n /= i, PFs.insert(i);
if (n > 1) // o próprio número é primo
PFs.insert(n);
}
int main() {
ll n; cin >> n;
primeFactors(n);
// qte de todos subconjuntos possíveis - qte de subconjuntos de 1 elem - subconjunto vazio
cout << pow(2, PFs.size()) - PFs.size() - 1 << endl;
return 0;
}