hdu 5224 Tom and paper
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5224
Tom and paper
Description
There is a piece of paper in front of Tom, its length and width are integer. Tom knows the area of this paper, he wants to know the minimum perimeter of this paper.
Input
In the first line, there is an integer T indicates the number of test cases. In the next T lines, there is only one integer n in every line, indicates the area of paper.
$T\leq 10,n\leq {10}^{9}$
Output
For each case, output a integer, indicates the answer.
Sample Input
3
2
7
12
Sample Output
6
16
14
1 #include<algorithm> 2 #include<iostream> 3 #include<cstdlib> 4 #include<cstring> 5 #include<cstdio> 6 #include<vector> 7 #include<map> 8 using std::min; 9 using std::cin; 10 using std::cout; 11 using std::endl; 12 using std::find; 13 using std::sort; 14 using std::map; 15 using std::pair; 16 using std::vector; 17 using std::multimap; 18 #define pb(e) push_back(e) 19 #define sz(c) (int)(c).size() 20 #define mp(a, b) make_pair(a, b) 21 #define all(c) (c).begin(), (c).end() 22 #define iter(c) decltype((c).begin()) 23 #define cls(arr,val) memset(arr,val,sizeof(arr)) 24 #define cpresent(c, e) (find(all(c), (e)) != (c).end()) 25 #define rep(i, n) for (int i = 0; i < (int)(n); i++) 26 #define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i) 27 const int Max_N = 100010; 28 const int INF = ~0u >> 1; 29 typedef unsigned long long ull; 30 void solve(int n) { 31 int ans = INF; 32 for (int i = 1; (ull)i * i <= n; i++) { 33 if (n % i == 0) ans = min(ans, (i + n / i) << 1); 34 } 35 printf("%d\n", ans); 36 } 37 int main() { 38 #ifdef LOCAL 39 freopen("in.txt", "r", stdin); 40 freopen("out.txt", "w+", stdout); 41 #endif 42 int t, n; 43 scanf("%d", &t); 44 while (t--) { 45 scanf("%d", &n); 46 solve(n); 47 } 48 return 0; 49 }
View Code
转载于:https://www.cnblogs.com/GadyPu/p/4617008.html
hdu 5224 Tom and paper相关推荐
- HDU 5224 Tom and paper(最小周长)
HDU 5224 Tom and paper(最小周长) Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d &a ...
- 组合数(Lucas定理) + 快速幂 --- HDU 5226 Tom and matrix
Tom and matrix Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=5226 Mean: 题意很简单,略. analy ...
- HDU 5226 Tom and matrix(组合数学+Lucas定理)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5226 题意:给一个矩阵a,a[i][j] = C(i,j)(i>=j) or 0(i < ...
- HDU 5224(最小周长)
题目[点击即可] 解题思路:原来用循环每次都超时,循环没有找到最小的范围,所以每次都超时了,最后找到最小范围了,n的平方根. #include<iostream> #include< ...
- python 第三方包自动导入_7行代码,彻底告别python第三方包import导入问题!
最近有不少小伙伴咨询关于pyton第三方包导入的问题,今天我们就来聊聊第三方包导入那些事. 随着对python学习的渐入臻境,越来越多的小伙伴们开始导入自己所需的第三方包,实现各种各样的功能.但是,他 ...
- 机器学习知识点(三十)LDA话题模型Java实现
1.LDA数学定义 1)话题模型:传统的文本分类器,比如贝叶斯.kNN和SVM,只能将其分到一个确定的类别中.假设我给出3个分类"算法""分词""文学 ...
- highcharts ajax 数据格式,Highcharts ajax获取json对象动态生成报表生成 .
最近做个项目,项目经理想做一个统计报表,在网上查看些资料就选用Highchars 这里和大家分享下使用心得. 重点说明此代码是针对一个报表显示多个项对比显示. 直接贴代码:web端 $(documen ...
- linux在硬盘建文件,Linux在向磁盘新建文件的时候在系统层面的四步操作
android 帧动画 首先在res/drawable/name1.xml/定义一组图片集合: <?xml version="1.0" encoding="utf- ...
- CVPR 2011 全部论文标题和摘要
CVPR 2011 Tian, Yuandong; Narasimhan, Srinivasa G.; , ■Rectification and 3D reconstruction of curved ...
最新文章
- 怎么用Leangoo管理Bug
- JQuery eval函数
- IP通信基础 4月1日
- python最常用的版本、也称为classic_2021年中国大学《创新思维与创业》单元测试答案...
- 面试题,你什么时候可以入职?回答不好,容易被压薪资
- android parcel空指针,android - intent.hasExtra(“ meta”)抛出错误的可包裹异常 - 堆栈内存溢出...
- layui数据表格格式化
- 程序员面试宝典(第三版).pdf
- 如何在Ubuntu18.4中设置ERPNEXT开源ERP生产环境开机运行
- 【小5聊】2021年度总结,回顾 2021,展望 2022
- 在线教育APP的功能和优势
- 如何用GraphPad Prism 进行pearson相关性分析
- vbs 打开指定浏览器网页
- CVPR 2022 Oral|港中文开源PoseC3D:基于3D-CNN的骨骼动作识别框架
- 智慧金融系统软件需求规格说明(IEEE 830 标准)最终版
- Matlab 指定分辨率保存图片
- 广州大学2021计算机组成原理课程设计实验报告
- LOTO 示波器软件功能——文件存储和回读功能
- 智能锁行业进入视频时代,如何定义一把好的视频锁?
- 在线评测系统设计与实现