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);
}

upc组队赛12 Cardboard Container【枚举】的更多相关文章

  1. upc组队赛6 GlitchBot【枚举】

    GlitchBot 题目描述 One of our delivery robots is malfunctioning! The job of the robot is simple; it shou ...

  2. upc组队赛12 Janitor Troubles【求最大四边形面积】

    Janitor Troubles Problem Description While working a night shift at the university as a janitor, you ...

  3. upc组队赛6 Odd Gnome【枚举】

    Odd Gnome 题目描述 According to the legend of Wizardry and Witchcraft, gnomes live in burrows undergroun ...

  4. upc组队赛17 Bits Reverse【暴力枚举】

    Bits Reverse 题目链接 题目描述 Now given two integers x and y, you can reverse every consecutive three bits ...

  5. upc组队赛5 Ground Defense【枚举】

    Ground Defense 题目描述 You are a denizen of Linetopia, whose n major cities happen to be equally spaced ...

  6. upc组队赛2 Super-palindrome【暴力枚举】

    Super-palindrome 题目描述 You are given a string that is consisted of lowercase English alphabet. You ar ...

  7. [易学易懂系列|rustlang语言|零基础|快速入门|(12)|Enums枚举]

    [易学易懂系列|rustlang语言|零基础|快速入门|(12)] 有意思的基础知识 Enums 今天我们来讲讲枚举. 在数学和计算机科学理论中,一个集的枚举是列出某些有穷序列集的所有成员的程序,或者 ...

  8. upc组队赛3 Chaarshanbegaan at Cafebazaar

    Chaarshanbegaan at Cafebazaar 题目链接 http://icpc.upc.edu.cn/problem.php?cid=1618&pid=1 题目描述 Chaars ...

  9. upc组队赛18 THE WORLD【时间模拟】

    THE WORLD 题目链接 题目描述 The World can indicate world travel, particularly on a large scale. You mau be l ...

随机推荐

  1. ubuntu snap 包管理器

    基本使用 snap find $package snap install $package [--channel=beta] snap list snap refresh $package [--ch ...

  2. cesium加载gltf模型

    cesium加载gltf模型 一.采用vue-cesium:在项目里加载依赖包.命令如下: npm i --save vue-cesium 在main.js中加入如下代码: https://www.n ...

  3. Python 2 将死,你准备好了吗?

    Python 软件基金会宣布,到 2020 年元旦,将不再为编程语言 Python 2.x 分支提供任何支持.这一天将标志着一出延续多年的戏剧的高潮:Python 从较旧的.功能较弱的.广泛使用的版本 ...

  4. 使用vue配合组件--转载

    1.由饿了么 UED (知乎专栏)设计的桌面端组件库已经开源,文档:Element,仓库: GitHub - ElemeFE/element: Desktop UI elements for Vue. ...

  5. 领域驱动设计(DDD:Domain-Driven Design) 转摘自:http://www.jdon.com/ddd.html

    Eric Evans的“Domain-Driven Design领域驱动设计”简称DDD,Evans DDD是一套综合软件系统分析和设计的面向对象建模方法,本站Jdon.com是国内公开最早讨论DDD ...

  6. go中整型的用法小结

    示例 // 整型的用法小结 // 注意: // 整型变量在使用时,遵循保小不保大的原则 // 尽量使用占用空间小的数据类型 package main import ( "fmt" ...

  7. JavaScript寻找最长的单词算法

    返回提供的句子中最长的单词的长度. 返回值应该是一个数字. 第一步,使用String.prototype.split()方法将字符串转换成数组 function findLongestWord(str ...

  8. mybatis-generator 代码自动生成插件

    Hibernate 可以选择MyEclipse Datebase Explorer 或者是 Hibernate-tools 等工具来自动生成映射文件和实体类. mybatis 当然也要有!下面简单介绍 ...

  9. day13 python生成器函数 推导式 生成器

    day13 python   一.生成器     生成器的本质就是迭代器     生成器的特点和迭代器一样. 取值方式和迭代器一样(__next__())     由生成器函数或生成器表达式来创建   ...

  10. Spring高频率面试题

    1.Spring怎样定义类的作用域 通过bean 定义中的scope属性来定义. 2.Spring支持的几种bean的作用域 支持以下五种bean的作用域: singleton : bean在每个Sp ...