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为偶数时,显 ...
随机推荐
- Quartz是一个任务调度
这段时间做一个案子,用到每天定时处理事件,之前的解决思路是通过一个定时器轮询时间段,这样不能精准的在某个时间戳上执行动作.由于没有用过Quartz是一个任务调度,一直使用这个办法,今天通过同事提点,从 ...
- CF1082解题报告
CF1082A Vasya and Book 模拟一下即可 \(Code\ Below:\) #include <bits/stdc++.h> using namespace std; c ...
- Java内存溢出问题总结
使用Java那么久,在此总结一下Java中常见的内存溢出问题以及对应的解决思路 堆溢出 报错信息 java.lang.OutOfMemoryError: Java heap space 报错原因 堆中 ...
- Python小白学习之路(二十五)—【装饰器的应用】
通过一个任务来加深对装饰器的理解和应用 回顾:装饰器的框架 def timmer(func): def wrapper(): func() return wrapper 任务:给以下正在运行的程序加一 ...
- java filter过滤器及责任链设计模式
什么是Filter? Filter属于sevlet规范,翻译为过滤器. Filter在web开发中有什么作用? 案例一:一个web站点只有用户登录才能继续访问该站点的资源,那么需要用户每次访问都判断是 ...
- Python 模块 和 包
模块 os模块 路径拼接 os.path.join
- c++中double类型控制小数位数
有时,我们需要输出确定小数位数的double,可以先引入如下头文件: #include <iomanip> 然后通过下列方式输出: double zzz = 8.66666; cout & ...
- 全网最详细的HBase启动以后,HMaster进程启动了,几秒钟以后自动关闭问题的解决办法(图文详解)
不多说,直接上干货! 问题详情 情况描述如题所示,hbase启动以后,HMaster进程启动了,几秒钟以后自动关闭,但是HRegionServer进程正常运行: 解决办法: 1.检查下每台机器的时间是 ...
- 【云和恩墨】性能优化:Linux环境下合理配置大内存页(HugePage)
原创 2016-09-12 熊军 [云和恩墨]性能优化:Linux环境下合理配置大内存页(HugePage) 熊军(老熊) 云和恩墨西区总经理 Oracle ACED,ACOUG核心会员 PC S ...
- java实现微信支付
java实现微信支付 package com.hk.wx.pay.service.impl; @Service public class PayServiceImpl implements PaySe ...