Cardboard Container

Problem Description

fidget spinners are so 2017; this years’ rage are fidget cubes. A fidget cube is a cube with unit side lengths, which you hold in your hand and fidget with. Kids these days,right?

You work in the planning department for a company that creates and ships fidget cubes. Having done some market analysis, you found that your customers want to receive shipments of exactly V fidget cubes.

This means you have to design a container that will hold exactly V fidget cubes. Since fidget cubes are very fragile, you cannot have any empty space in your container. If there is empty space, they might move around, bump into each other and get damaged. Because of this, you decide to ship the fidget cubes in a rectangular cardboard box.

The cost of a cardboard box is proportional to its surface area, costing exactly one unit of money per square unit of surface area. Of course you want to spend as little money as possible. Subject to the above constraints, how much money do you have to spend on a box for V fidget cubes?

Input

Input

The input contains a single integer, 1 ≤ V ≤ 106, the number of fidget cubes for which you need to build a box.

Output

Print the cost of the cheapest rectangular box as specified in the statement.

Sample Input

1

Sample Output

6

题意

求n个立方体小块叠成一个大立方体形成的最小表面积

题解

枚举长和宽,表面积 = 2*((长+宽)+(长+高)+(宽+高)),取最小的

代码

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define scac(x) scanf("%c",&x)
#define pri(x) printf("%d\n",x)
#define pri2(x,y) printf("%d %d\n",x,y)
#define pri3(x,y,z) printf("%d %d %d\n",x,y,z)
#define prl(x) printf("%lld\n",x)
#define prl2(x,y) printf("%lld %lld\n",x,y)
#define prl3(x,y,z) printf("%lld %lld %lld\n",x,y,z)
#define ll long long
#define LL long long
inline ll read(){ll x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;}
#define read read()
#define pb push_back
#define mp make_pair
#define P pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(1.0)
#define eps 1e-6
#define inf 1e17
#define INF 0x3f3f3f3f
#define MOD 998244353
#define mod 1e9+7
#define N 2000005
const int maxn=2e5+5;
int n;
ll ans;
int main()
{
n = read;
ans = INF;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n/i && j <= i; j++){
if(n%(i * j)!=0) continue;
int k = n/(i * j);
ans = min(ans,(ll)2*(i*j + i*k + j*k));
}
prl(ans);
}

最新文章

  1. PHP数据类型之间的强制转换
  2. 即使用ADO.NET,也要轻量级实体映射,比Dapper和Ormlite均快
  3. 分析‖为什么越来越多厂商开始发力VR一体机?
  4. 【读书笔记】iOS-ASIHTTPRequest框架的使用。
  5. 字符串数组(String []) 去掉重复值的方法
  6. [转]source inslght使用指导
  7. 获取当前访问的url
  8. JIT(动态编译)和AOT(静态编译)编译技术比较
  9. Windows Phone中的图形渲染处理
  10. 聊聊 #pragma 和 // MARK:
  11. 定制属于自己的Chrome起始页
  12. 使用cocoapods后 三方库的头文件没有代码提示?
  13. Union - Find 、 Adjacency list 、 Topological sorting Template
  14. 一步一步实现FormsAuthentic验证登录
  15. C# 4.0 Parallel
  16. linux截取字符串之sort、uniq、cut用法
  17. python面试题整理
  18. django.db.utils.OperationalError: (1045, &quot;Access denied for user &#39;ODBC&#39;@&#39;localhost&#39; (using password)
  19. Divide the Sequence (贪心)
  20. PAT A1117 Eddington Number (25 分)——数学题

热门文章

  1. Python中的浮点数原理与运算分析
  2. MVC和WebApi 使用get和post 传递参数。 转载https://blog.csdn.net/qq373591361/article/details/51508806
  3. LightOJ 1418 Trees on My Island (Pick定理)
  4. md5加密 和拉钩网的登录
  5. JavaScript Stack
  6. five hundred miles
  7. HDU 1387 Team Queue( 单向链表 )
  8. 中文字符集编码unicode,gb2312,cp936,GBK,GB18030介绍
  9. HTML 使用CSS 如何去掉文本聚焦框 HTML 使用CSS 如何去掉文本聚焦框 : outline 值设为none 修改input、textarea输入框placeholder样式
  10. gcc 交叉工具链中工具使用(arm-linux-xxx)