本文共 1178 字,大约阅读时间需要 3 分钟。
题目链接:
暴力
1 //#pragma comment(linker, "/STACK:102400000, 102400000") 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 using namespace std;14 typedef long long LL;15 typedef pair P;16 const int N = 1e5 + 5;17 int a[20];18 LL ans, p[] = { 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29}, limit = 1e18;19 20 void dfs(int num, int len) {21 if(num == 1) {22 LL res = 1;23 for(int i = 1; i <= len; ++i) {24 for(int j = 1; j < a[i]; ++j) {25 if(limit / p[i] <= res) {26 return ;27 }28 res *= p[i];29 }30 }31 ans = min(ans, res);32 return ;33 }34 for(int i = 2; i <= num; ++i) {35 if(num % i == 0) {36 a[len + 1] = i;37 dfs(num / i, len + 1);38 }39 }40 }41 42 int main()43 {44 int n;45 cin >> n;46 if(n == 1) {47 cout << 1 << endl;48 return 0;49 } else if(n == 2) {50 cout << 2 << endl;51 return 0;52 }53 ans = limit;54 for(int i = 1; i <= n; ++i) {55 if(n % i == 0) {56 a[1] = i;57 dfs(n/i, 1);58 }59 }60 cout << ans << endl;61 return 0;62 }
转载于:https://www.cnblogs.com/Recoder/p/5934638.html