upc组队赛12 Cardboard Container【枚举】
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【枚举】的更多相关文章
- upc组队赛6 GlitchBot【枚举】
GlitchBot 题目描述 One of our delivery robots is malfunctioning! The job of the robot is simple; it shou ...
- upc组队赛12 Janitor Troubles【求最大四边形面积】
Janitor Troubles Problem Description While working a night shift at the university as a janitor, you ...
- upc组队赛6 Odd Gnome【枚举】
Odd Gnome 题目描述 According to the legend of Wizardry and Witchcraft, gnomes live in burrows undergroun ...
- upc组队赛17 Bits Reverse【暴力枚举】
Bits Reverse 题目链接 题目描述 Now given two integers x and y, you can reverse every consecutive three bits ...
- upc组队赛5 Ground Defense【枚举】
Ground Defense 题目描述 You are a denizen of Linetopia, whose n major cities happen to be equally spaced ...
- upc组队赛2 Super-palindrome【暴力枚举】
Super-palindrome 题目描述 You are given a string that is consisted of lowercase English alphabet. You ar ...
- [易学易懂系列|rustlang语言|零基础|快速入门|(12)|Enums枚举]
[易学易懂系列|rustlang语言|零基础|快速入门|(12)] 有意思的基础知识 Enums 今天我们来讲讲枚举. 在数学和计算机科学理论中,一个集的枚举是列出某些有穷序列集的所有成员的程序,或者 ...
- upc组队赛3 Chaarshanbegaan at Cafebazaar
Chaarshanbegaan at Cafebazaar 题目链接 http://icpc.upc.edu.cn/problem.php?cid=1618&pid=1 题目描述 Chaars ...
- upc组队赛18 THE WORLD【时间模拟】
THE WORLD 题目链接 题目描述 The World can indicate world travel, particularly on a large scale. You mau be l ...
随机推荐
- 【读书笔记】:MIT线性代数(3):Special Solution, Rank and RREF
Special Solutions: Notice what is special about s 1 and S2. They have ones and zeros in the last two ...
- JS高级程序随笔一
function Aarguments(x,y){ for(var i=0;i<arguments.length;i++){ alert(arguments[i]); }; }; Aargume ...
- 如何使用 C++ Inja html template 模板
C++ html template Inja是现代C ++的模板引擎,受到jinja for python的启发.它有一个简单而强大的模板语法,包含所有变量,循环,条件,包含,回调,您需要的注释,嵌套 ...
- 【转】C++ STL中常见容器的时间复杂度
map, set, multimap, and multiset 上述四种容器采用红黑树实现,红黑树是平衡二叉树的一种.不同操作的时间复杂度近似为: 插入: O(logN) 查看:O(logN) 删除 ...
- columns样式属性使用
columns样式属性使用 columns:用于设置元素的列宽和列数.它是column-width和column-count的简写属性. 语法: columns: <'column-width' ...
- React-Native基础-安卓篇(二)
前言:这一篇随笔将记录我在React-Native官网文档上学习的基础知识
- 联想think system sr550信息
带外管理口 默认IP地址:192.168.70.125 默认用户名密码 USERID PASSW0RD 0是数字0
- 转载:HTTP详解
第一部分: 1. HTTP简介 HTTP 协议(HyperText Transfer Protocol,超文本传输协议)是用于从WWW服务器传输超文本到本地浏览器的传送协议.它可以使浏览器更加高效,使 ...
- Java网络编程:OSI七层模型和TCP/IP模型介绍
OSI(Open System Interconnection),开放式系统互联参考模型 .是一个逻辑上的定义,一个规范,它把网络协议从逻辑上分为了7层.每一层都有相关.相对应的物理设备,比如常规的路 ...
- C++ 之获取map元素[转]
链接:https://www.cnblogs.com/jianfeifeng/p/11089799.html 对于map对象, count成员返回值只能是0或者1,map容器只允许一个键对应一个实例. ...