hdu 6154 CaoHaha's staff
CaoHaha's staff
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 487 Accepted Submission(s): 286
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.
Then T lines each contains one intetger S.The size of the toy(N<=1e9).
题意:
一笔可以画一条长为1的边或者一条根号二的对角线,问围成一个面积是n 的图形最少需要几条边
题解:
找规律画图
这题可以先把问题转化为已知画m笔,最大可以画出多大的面积
当m%4==0,画sqrt(2)的边,可以达成最大的面积
当m%4==1,就把[m/4]*4围成的图像的 最长边往外推sqrt(2)/2,比原来增加一个梯形的面积
当m%4==2,就把[m/4]*4围成的图像的 最长边往外推sqrt(2)长度,增加一个小矩形面积
当m%4==3,在m%4==2的基础上实行m%4==1一样的操作
#include <iostream>
#include<bits/stdc++.h>
using namespace std; int t;
int n,sd; int sumS(int m) //m是周长,推出公式就可以了
{
int d=m/;
if (m%==) return *d*d;
if (m%==) return *d*d+d-;
if (m%==) return *d*d+*d;
if (m%==) return *d*d+*d;
}
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
sd=(int)sqrt(n/2.0)*; //最小的周长
while()
{
if (sumS(sd)>=n) {printf("%d\n",sd); break;}
sd++;
}
}
return ;
}
hdu 6154 CaoHaha's staff的更多相关文章
- HDU 6154 - CaoHaha's staff | 2017 中国大学生程序设计竞赛 - 网络选拔赛
/* HDU 6154 - CaoHaha's staff [ 构造,贪心 ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛 题意: 整点图,每条线只能连每个方格的边或者对角线 问面积大于n的 ...
- HDU 6154 CaoHaha's staff(2017中国大学生程序设计竞赛 - 网络选拔赛)
题目代号:HDU 6154 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6154 CaoHaha's staff Time Limit: 2000/1 ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6154 CaoHaha's staff(几何找规律)
Problem Description "You shall not pass!"After shouted out that,the Force Staff appered in ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 1005 HDU 6154 CaoHaha's staff (找规律)
题目链接 Problem Description "You shall not pass!" After shouted out that,the Force Staff appe ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6154 CaoHaha's staff 思维
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6154 题意:在笛卡尔坐标系下,画一个面积至少为 n 的简单多边形,每次只能画一条边或者一个格子的对角 ...
- CaoHaha's staff (HDU 6154)(2017中国大学生程序设计竞赛 - 网络选拔赛)
Problem Description "You shall not pass!" After shouted out that,the Force Staff appered i ...
- 【2017中国大学生程序设计竞赛 - 网络选拔赛 && hdu 6154】CaoHaha's staff
[链接]点击打开链接 [题意] 给你一个面积,让你求围成这个面积最少需要几条边,其中边的连线只能是在坐标轴上边长为1的的线或者是两个边长为1 的线的对角线. [题解] 找规律题 考虑s[i]表示i条边 ...
- 【推导】【找规律】【二分】hdu6154 CaoHaha's staff
题意:网格图.给你一个格点多边形的面积,问你最少用多少条边(可以是单位线段或单位对角线),围出这么大的图形. 如果我们得到了用n条边围出的图形的最大面积f(n),那么二分一下就是答案. n为偶数时,显 ...
- HDU6154
CaoHaha's staff Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
随机推荐
- python修改镜像源
pip升级:python -m pip install --upgrade pip https://www.cnblogs.com/andy9468/p/10319442.html 1.在命令中临时修 ...
- jQuery Form
https://github.com/jquery-form/form#type 概念 jQuery表单插件允许您轻松,无差错地升级HTML表单以使用AJAX. 主要方法ajaxForm和ajaxSu ...
- Spark UI (基于Yarn) 分析与定制
转载自:https://yq.aliyun.com/articles/60194 摘要: 这篇文章的主旨在于让你了解Spark UI体系,并且能够让你有能力对UI进行一些定制化增强.在分析过程中,你也 ...
- MongoDB之Replica Set(复制集复制)
MongoDB支持两种复制模式: 主从复制(Master/Slave) 复制集复制(Replica Set) 下面主要记录我在centos虚拟机上安装replica set,主要参考:http://d ...
- enum 枚举类型默认值
enum value { one, two, three, four }; 默认值
- C++ string 类
标准c++中string类函数介绍 注意不是CString之所以抛弃char*的字符串而选用C++标准程序库中的string类,是因为他和前者比较起来,不必 担心内存是否足够.字符串长度等等,而且作为 ...
- 35. Search Insert Position(二分查找)
Given a sorted array and a target value, return the index if the target is found. If not, return the ...
- zw版【转发·台湾nvp系列Delphi例程】HALCON union1
zw版[转发·台湾nvp系列Delphi例程]HALCON union1 unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, ...
- windows监听socket和标准输入
原来的代码 def input_command(self): msg = raw_input('\nPlease input the command:') remote_id = raw_input( ...
- Refactoring #001 Extract Method
Example public void startup() { ServerSocket serverSocket = null; try { serverSocket = new ServerSoc ...