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 ...
随机推荐
- POJ -1062 昂贵的聘礼(前向星 && SPFA)
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u013497151/article/details/30299671 题目链接:id=1062&qu ...
- 用ildasm/ilasm修改IL代码(操作步骤)
在开发中遇到这样一个场景,需要修改一个dll文件(.NET程序集)中某些地方的类型名称,但没有源代码,只能修改IL代码. 操作步骤如下: 1. 运行ildasm ildasm是由微软提供的.NET程序 ...
- Django RF:学习笔记(8)——快速开始
Django RF:学习笔记(8)——快速开始 安装配置 1.使用Pip安装Django REST Framework: pip install djangorestframework 2.在Sett ...
- Yahoo Programming Contest 2019
A - Anti-Adjacency 签. #include <bits/stdc++.h> using namespace std; int main() { int n, k; whi ...
- uva11020 set
有n个人,每个人有两个属性x,y.如果对于一个人P(x,y) 不存在另外一个人(x',y') 使得x'<x,y'<=y 或者 x'<=x,y'<y 我们说p是有优势的,每次给出 ...
- 20155307 2016-2017-2 《Java程序设计》第8周学习总结
20155307 2016-2017-2 <Java程序设计>第8周学习总结 教材学习内容总结 日志API:使用日志的起点是Logger类,要取得Logger类,必须使用Logger的静态 ...
- MapReduce: map读取文件的过程
我们的输入文件 hello0, 内容如下: xiaowang 28 shanghai@_@zhangsan 38 beijing@_@someone 100 unknown 逻辑上有3条记录, 它们以 ...
- SQL 根据条件取不同列中的值来排序
1 有时候排序比较复杂,比如:领导对工资在1000到2000元之间的员工更感兴趣,于是要求工资在这个范围内的员工排在前面,以便优先查看 对于这种要求我们可以在查询中新生成一列,用多列排序的方法处理代 ...
- ABP官方文档翻译 0.0 ABP官方文档翻译目录
一直想学习ABP,但囿于工作比较忙,没有合适的契机,当然最重要的还是自己懒.不知不觉从毕业到参加工作七年了,没留下点儿什么,总感觉很遗憾,所以今天终于卯足劲鼓起勇气开始写博客.有些事能做的很好,但要跟 ...
- 详细了解下PHP的curl函数及常用之处
CURL 是一个利用URL语法规定来传输文件和数据的工具,支持很多协议,如HTTP.FTP.TELNET等,我们使用它来发送HTTP请求.正因为这么强大,当然PHP也支持 CURL 库,前提是你的ph ...