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. day 67 Django的view 与路由

    一.Django中的视图 CBV和FBV 我们之前写过的都是基于函数的view,就叫FBV.还可以把view写成基于类的. url(r'^add_publisher/',views.AddPublis ...

  2. shell cp拷贝的用法

    个人觉得这个记录的比较全 自己查阅: cp [options] <source file or directory> <target file or directory> 或 ...

  3. Raft Paper 简译

      本文是对 Raft Paper 核心部分的意译,不包括原文中的如下章节:<3 Paxos 的优缺点论述>.<4 Raft 的易理解性介绍>.<9 Raft 算法的易理 ...

  4. BootStrap自定义轮播图播放速度

    $('.carousel').carousel({      interval: 3000 });

  5. vue-router 传递参数的几种方式

    本文转载自:https://blog.csdn.net/crazywoniu/article/details/80942642 vue-router传递参数分为两大类 编程式的导航 router.pu ...

  6. FastJSON 远程执行漏洞,速速升级!

    相信大家用 FastJSON 的人应该不少,居然有漏洞,还不知道的赶紧往下看,已经知道此漏洞的请略过-- 2019年6月22日,阿里云云盾应急响应中心监测到FastJSON存在0day漏洞,攻击者可以 ...

  7. springCloud的使用08-----服务链路追踪(sleuth+zipkin)

    sleuth主要功能是在分布式系统中提供追踪解决方案,并且兼容支持了zipkin(提供了链路追踪的可视化功能) zipkin原理:在服务调用的请求和响应中加入ID,表明上下游请求的关系. 利用这些信息 ...

  8. go 学习之函数

    个人把go函数理解分三种: 1.普通函数 普通函数声明: func name(parameter-list) (result-list) { body} package main import &qu ...

  9. 使用VS 2019发布.net core程序并部署到IIS的最新教程

    不管你是使用.net core开发的是web api还是网站类的程序,如果你是部署到IIS,那么下面的内容都适合于你,不会将.net core程序部署到IIS的朋友,可以看看这篇手把手教你部署.net ...

  10. Elasticsearch学习,请先看这一篇

    题记: Elasticsearch研究有一段时间了,现特将Elasticsearch相关核心知识.原理从初学者认知.学习的角度,从以下9个方面进行详细梳理.欢迎讨论-- 0. 带着问题上路--ES是如 ...