C Cardboard Container
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.
Time limit: 1s
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
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 Input 2
Sample Input 3
Sample Input 4
Sample Output 1
Sample Output 2
Sample Output 3
Sample Output 4
1
6
4
16
3
14
5913
2790

题意: 已知体积求最小表面积
思路: 枚举长宽高就可以了。枚举高的过程就是在枚举体积的公因数.

#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;typedef long long ll;int main()
{int n;scanf("%d",&n);int tmp = sqrt(n) + 1;int ans = 0x3f3f3f3f;for(int i = 1;i <= n;i++){if(n % i == 0){for(int j = 1;j <= n / i;j++){if(n % (i * j) == 0){int z = n / (i * j);ans = min(ans,i * j * 2 + i * z * 2 + j * z * 2);}}}}printf("%d\n",ans);return 0;
}

C - Cardboard Container Gym - 102007C(已知体积求表面积)相关推荐

  1. 【C语言】圆球体计算:已知球的表面积公式为s=4πr2,体积公式为v=4/3πr3,若公式中π取值为3.14159,编写程序,输入半径r,输出球的表面积和体积。 个人题解

    圆球体计算:已知球的表面积公式为s=4πr2,体积公式为v=4/3πr3,若公式中π取值为3.14159,编写程序,输入半径r,输出球的表面积和体积. #include <stdio.h> ...

  2. C语言--已知三边求三角形面积

    已知三边求面积用海伦公式S=sqrt[p(p-a)(p-b)(p-c)] p=(a+b+c)/2 #include<stdio.h> #include<math.h> int ...

  3. 已知分布函数求概率密度例题_高中数学必修一函数知识点总结

    同学们,今天开始讲解函数章节学习,函数这章极其重要,因为函数是高中数学重要的枢纽章节,高中数学除了立体几何和概率统计和函数没有关系之外,所有章节多多少少和函数有关系,所以函数学不好高中数学很难突破10 ...

  4. 海伦公式已知三边求面积

    已知三边求面积 import matha = float(input('a = ')) b = float(input('b = ')) c = float(input('c = ')) if a + ...

  5. 已知函数和y值求自变量用matlab,matlab已知函数值求自变量,求助

    思路是这样的:你得到最小的函数值后,把它带入你作图的方程反解自变量的值.我不知道你画的这个函数图像的方程什么,我用一个二次方程y=x.^2+x给你做示范:先做图:x=-10:0.1:10;y=x.^2 ...

  6. 已知坐标求方位角_【干货】RTK视频实操 | 求转换参数详解和七点注意事项!

    RTK视频教学,『求转换参数』,技术员结合测量一线实操经验,运用工程之星5.0软件为大家讲解如何求转换参数,以及求转换参数需要注意哪些事项. 求转换参数操作 通常情况下,科力达工程之星直接输出的坐标为 ...

  7. 税收问题的分析:已知税后收入求税前、年终奖一元陷阱的分析

    早上家里来了个客人,聊天中得知了他的税后收入于是蛮好奇他的税前收入是多少. 顺便开了一下脑洞,想证明一下当前年终奖税收模型下,是否存在合理的税率及税收安排,使得"一元陷阱"得以避免 ...

  8. python怎么根据点来拟合曲线_2019_nCoV_利用python根据已知点求拟合曲线及简单预测(无实际意义)...

    前言 本文仅做根据已知点求拟合曲线的几种方法的python实现,无任何实际意义 数据来源(另一篇博文) 利用Python爬取新冠肺炎疫情实时数据,Pyecharts画2019-nCoV疫情地图 参考 ...

  9. c语言编程题输入两个直角边,C语言编程 直角三角形已知两边求第三边

    C语言编程题 求大神解答 好久没写C了,不知道对不对:intsum=0;intindex=0;for(;indexsum+=a[2][index];}returnsum; C语言编程题,求分段函数 刚 ...

最新文章

  1. 向量空间模型(VSM)在文档相似度计算上的简单介绍
  2. OpenCV 之 直方图处理
  3. 数据结构实验之栈四:括号匹配
  4. 解开 Windows 下的临界区中的代码死锁(转)
  5. 分布式系统最终一致性
  6. Acer 4750 安装黑苹果_黑苹果 Mac OS 10.14.5 Mojave 安装
  7. Unity3d如何制作声音开关按钮
  8. 机械加工工艺师手册_这些机械加工工艺,你见过吗?
  9. 没有apihost什么意思_热文:2021年没有立春什么意思
  10. Python爬虫之小说信息爬取与数据可视化分析
  11. Symbian游戏编程入门 (一) Symbian OS简介
  12. 油猴插件安装以及好用的脚本推荐
  13. Mac OS下FileVault encryption 使用原理与简介
  14. Centos 7 安装 ifconfig命令
  15. 阿里巴巴数字化运营能力
  16. 高性能无线综合测试仪 无线电综合测试仪 ---TFN PM5100 100KHz-1GHz
  17. Jetson 基本笔录
  18. 推荐一种英语听力筑基训练方法
  19. Mento Carlo方法
  20. OpenLayers结合Turf实现空间运算

热门文章

  1. 计算机上下打字怎么打,电脑打字符号怎么打底下的一横
  2. 完美的alert美化
  3. 2018清华计算机类专业录取分数线,2020清华大学录取分数线汇总(含2018-2019历年)...
  4. cocos2d-x Touch触屏事件
  5. Uber Thomas 论文整理
  6. 170716 网线接口顺序
  7. [附源码]java毕业设计医疗预约系统
  8. app inventor+tinywebDB远程控制掌控板
  9. JAVA要不要看源码_为什么要看源码、如何看源码,高手进阶必看
  10. <JVM笔记:内存与垃圾回收>13-垃圾回收器