/*
ID: BryatnMark
LANG: JAVA
TASK: AC
*/
import java.util.*;
import java.io.*;
import java.math.*;
import java.util.*;
public class Solution {
public static void main(String args[]) throws Exception {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
Task solver = new Task();
solver.main(in, out);
out.close();
}
}
class InputReader {
BufferedReader reader;
StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream));
tokenizer = null;
}
public String next() {
if (!hasNext())
throw new RuntimeException();
return tokenizer.nextToken();
}
boolean hasNext() {
while (tokenizer == null || !tokenizer.hasMoreTokens())
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (Exception e) {
return false;
}
return true;
}
public long nextLong() {
return Long.parseLong(next());
}
public int nextInt() {
return Integer.parseInt(next());
}
public BigInteger nextBigInteger() {
return new BigInteger(next());
}
}
class Task {
PrintStream cout = System.out;
final int maxn = 100000;
int[] divisor = new int[maxn];
int[] p = new int[maxn];
int[] f = new int[maxn];
int[] c = new int[maxn];
double[] Log = new double[maxn];
int size = 0, cnt = 0;
BigInteger zero = BigInteger.ZERO;
BigInteger one = BigInteger.ONE;
BigInteger ans = zero;
boolean[] vis = new boolean[maxn + 10];
double log(double x) {
return Math.log(x);
}
void init() {
int i, j;
for (i = 2; i < 325; ++i)
if (!vis[i])
for (j = i * i; j <= maxn; vis[j] = true, j += i)
;
for (i = 2; i <= maxn; ++i)
if (!vis[i])
p[size++] = i;
for (i = 0; i < 100; ++i) {
Log[i] = log(p[i]);
}
}
void spilt(long n) {
int i;
cnt = 0;
divisor[cnt++] = (int) n;
for (i = 2; i * i <= n; ++i) {
if (n % i == 0) {
divisor[cnt++] = i;
if (i * i < n) {
divisor[cnt++] = (int) n / i;
}
}
}
}
long sqr(int n) {
return 1l * n * n;
}
int[] tmp = new int[105];
int[] res = new int[105];
int[] t;
long k;
double mul = 1e200;
BigInteger POW(BigInteger a, int k) {
BigInteger res = one;
while (k > 0) {
if ((k & 1) > 0)
res = res.multiply(a);
a = a.multiply(a);
k >>= 1;
}
return res;
}
void main(InputReader in, PrintWriter out) throws Exception {
init();
k = in.nextInt();
spilt(k);
Arrays.sort(divisor, 0, cnt);
int i = 0;
dfs(0, k, 1, 0);
ans = one;
for (i = 0; i < cnt; ++i) {
ans = ans.multiply(POW(BigInteger.valueOf(p[i]), res[i]));
}
out.println(ans);
}
void dfs(int x, long limit, long n, double m) {
if (n == k && m < mul) {
mul = m;
for(int i=0;i<25;++i)
res[i]=tmp[i];
}
if (n >= k || x > 20)
return;
int i;
double v;
for (i = 0; divisor[i] <= limit && i < cnt; ++i) {
v = m + (divisor[i] - 1) * Log[x];
if (v > mul)
break;
if (k % (n * divisor[i]) == 0) {
tmp[x] = divisor[i] - 1;
dfs(x + 1, divisor[i], n * divisor[i], v);
tmp[x] = 0;
}
}
}
}
SGU 473
最新推荐文章于 2022-09-04 18:54:44 发布