您的位置:首页 > 其它

[Coursera]算法基础_Week9_考试_Q4

2015-12-15 23:55 330 查看
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;

#define INF 1000000
int main()
{
int C;
cin >> C;
while (C--) {
int N;
cin >> N;
if (N == 0)
cout << 0 << endl;
int res = INF;
for (int a = 1; a <=N; a++) {
if (N%a != 0)
continue;
for (int b = 1; b <= N; b++) {
if ((N / a) % b != 0)
continue;
int c = N / a / b;
int temp = a*b + b*c + c*a;
if (res > temp)
res = temp;
}
}
cout << res * 2 << endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: