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为偶数时,显 ...
随机推荐
- [ZJOI2010]基站选址(线段树优化dp)
坑待填. \(Code\ Below:\) #include <bits/stdc++.h> #define lson (rt<<1) #define rson (rt< ...
- harbor镜像仓库-01-搭建部署
harbor镜像仓库-01-搭建部署 dockerregistryharbor安装部署docker-compose harbor的https配置参考另一章节harbor镜像仓库-02-https访问配 ...
- 将 Microsoft Excel 导入至 MySQL
将 Microsoft Excel 导入至 MySQL 一.前言 我得到了一份 Microsoft Excel 表格,里面记录了数据信息需要导入至 SQL 数据库. 如果只是导入数据,当然用 MSSQ ...
- updateByPrimaryKey 和 updateByPrimaryKeySelective
1. 数据库记录 2. updateByPrimaryKey Preparing: UPDATE t_token_info SET entity_id = ?,entity_type = ?,time ...
- Java - 集成开发环境Eclipse的使用方法和技巧
00 - Eclipse教程 Eclipse 教程 01 - Eclipse设置编译和运行的环境 建议编译和运行的版本保持一致,否则请特别注意: 低编译,高运行 ---> 可行. 高编译,低运行 ...
- 【xsy2194】Philosopher set+线段树合并
题目大意:给你一个长度为$n$的序列,有$m$次操作,每次操作是以下两种之一: 对某个区间内的数按照升序/降序排序,询问某个区间内数的积在十进制下首位数字是多少. 数据范围:$n,m≤2\times ...
- POJ 2853
#include<iostream> #include<stdio.h> #include<vector> #include<math.h> #incl ...
- 线程中的读写锁ReadWriteLock
Lock锁还有两个非常强大的类 ReadWriteLock接口实现类ReentrantReadWriteLock(非常重要的锁) 想实现 读取的时候允许多线程并发访问,写入的时候不允许. 这种效果.. ...
- Redis笔记(4)独立功能的实现
1.前言 本节记录一下redis的一些功能上的实现,包括发布订阅.事务.Lua脚本.排序.二进制位数组.慢查询日志和监视器. 2.发布订阅 上一章介绍sentinel的时候说到了sentinel会订阅 ...
- 推荐几个 WebSocket 服务端实现
http://netty.io/http://socket.io/https://github.com/StackExchange/NetGainhttps://github.com/SignalR/ ...