Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define MAXVAL int(1e8)
- bool primes[MAXVAL];
- int st[MAXVAL];
- int top;
- void precompute()
- {
- for (int i = 2; i <= MAXVAL; i++)
- primes[i] = true;
- for (int i = 2; i * i <= MAXVAL; i++)
- if (primes[i])
- {
- for (int j = i * i; j <= MAXVAL; j += i)
- primes[j] = false;
- }
- for (int i = 2; i <= MAXVAL; i++)
- if (primes[i])
- st[top++] = i;
- }
- int compute_ans(int n)
- {
- if (!n)
- return 0;
- if (n == 2)
- return 2;//*/
- int x = 0;
- while (true)
- {
- int temp = x;
- int total = 1, it = 0;
- for (int d = st[it]; d * d <= temp; d = st[++it])
- {
- int cnt = 0;
- while (temp % d == 0)
- {
- cnt++;
- temp /= d;
- }
- total *= (cnt + 1);
- }
- if (temp != 1)
- total *= 2;
- if (total == n)
- return x;
- x++;
- }
- }
- int main()
- {
- int n;
- cin >> n;
- precompute();
- cout << compute_ans(n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement