HDU6154
CaoHaha's staff
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 28 Accepted Submission(s): 17
Problem Description
After shouted out that,the Force Staff appered in CaoHaha's hand.
As we all know,the Force Staff is a staff with infinity power.If you can use it skillful,it may help you to do whatever you want.
But now,his new owner,CaoHaha,is a sorcerers apprentice.He can only use that staff to send things to other place.
Today,Dreamwyy come to CaoHaha.Requesting him send a toy to his new girl friend.It was so far that Dreamwyy can only resort to CaoHaha.
The first step to send something is draw a Magic array on a Magic place.The magic place looks like a coordinate system,and each time you can draw a segments either on cell sides or on cell diagonals.In additional,you need 1 minutes to draw a segments.
If you want to send something ,you need to draw a Magic array which is not smaller than the that.You can make it any deformation,so what really matters is the size of the object.
CaoHaha want to help dreamwyy but his time is valuable(to learn to be just like you),so he want to draw least segments.However,because of his bad math,he needs your help.
Input
Then T lines each contains one intetger S.The size of the toy(N<=1e9).
Output
Sample Input
1
2
3
4
5
Sample Output
4
6
6
7
Source
//2017-08-19
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath> using namespace std; int main()
{
int T, n;
scanf("%d", &T);
while(T--){
scanf("%d", &n);
int len = sqrt(n/);
int area = *len*len;
if(n-area == ){
printf("%d\n", len*);
}else if(n <= area+len-){
printf("%d\n", len*+);
}
else if(n-area <= *len){
printf("%d\n", len*+);
}else if(n <= *(len+)*(len+)-(len++)){
printf("%d\n", len*+);
}
else{
printf("%d\n", (len+)*);
}
} return ;
}
HDU6154的更多相关文章
- 【推导】【找规律】【二分】hdu6154 CaoHaha's staff
题意:网格图.给你一个格点多边形的面积,问你最少用多少条边(可以是单位线段或单位对角线),围出这么大的图形. 如果我们得到了用n条边围出的图形的最大面积f(n),那么二分一下就是答案. n为偶数时,显 ...
随机推荐
- padding(内边框), border(边框), margin, 标准文档流, 块级元素和行内元素, 浮动 ,margin的用法
盒模型 在CSS中,"box model"这一术语是用来设计和布局时使用,然后在网页中基本上都会显示一些方方正正的盒子.我们称为这种盒子叫盒模型. 盒模型有两种:标准模型和IE模型 ...
- 自用 docker-compose
version: '3.1' services: mysql: image: mysql: command: --default-authentication-plugin=mysql_native_ ...
- IE6下javascript:void(0)不可用的解决
<a href="javascript:void(0)" class="inp_sear_a" onclick="doSubmit();&quo ...
- SSH 学习笔记
零.背景 在看 pm2 的 deploy 功能的时候,对 ssh 的不熟悉导致错误频出,包括之前对 github 的配置也用到了 SSH,所以找个机会整理一下. 一.介绍 SSH 是每一台 Linux ...
- 实验1 C语言开发环境使用和数据类型、运算符、表达式
♦ 实验结论 PART 1 验证性内容 问题: 1.结尾没有加“:”时回车到下一行的时候再输入下一行的语言首字对齐方式会发生变化,可以对上一行进行检查. (这一点需要在不同软件里面试一下,在机房里的软 ...
- Linux学习系列之一:在centos 7.5上安装nginx 以及简单配置
说到Linux我们都知道那是相当相当得重要得啊,在计算机这个行业,开发运维都是离不开它得.我作为一个准毕业生,智商可能不太够,只能自己笨鸟先飞,自己操作起来咯.俗话说的好,好记性不如难笔头嘛.而且ng ...
- Git学习系列之Debian或Ubuntu上安装Git详细步骤(图文详解)
前言 最早Git是在Linux上开发的,很长一段时间内,Git也只能在Linux和Unix系统上跑.不过,慢慢地有人把它移植到了Windows上.现在,Git可以在Linux.Unix.Mac和Win ...
- Python基础内容
1.注释 #单行注释 ‘“多行注释”’ 2.变量 Python没有声明变量的过程(动态类型) 变量名=值,如果是浮点数就定义为浮点类型,如果是整型就定义为整型,如果是字符串就定义为字符串 3.输入和输 ...
- C#控件事件属性大全
C#控件及常用设计整 1.窗体... 1 2.Label 控件... 3 3.TextBox 控件... 4 4.RichTextBox控件... 5 5.NumericUpDown 控件... 7 ...
- 探讨e.target与e.currentTarget
target与currentTarget两者既有区别,也有联系,那么我们就来探讨下他们的区别吧,一个通俗易懂的例子解释一下两者的区别: <!DOCTYPE html> <html&g ...