HDU 6154 CaoHaha's staff
来源:互联网 发布:魔戒巫师知乎 编辑:程序博客网 时间:2024/06/05 00:38
CaoHaha's staff
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 731 Accepted Submission(s): 427
Problem Description
"You shall not pass!"
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.
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
The first line contains one integer T(T<=300).The number of toys.
Then T lines each contains one intetger S.The size of the toy(N<=1e9).
Then T lines each contains one intetger S.The size of the toy(N<=1e9).
Output
Out put T integer in each line ,the least time CaoHaha can send the toy.
Sample Input
512345
Sample Output
44667
题意:在方格中画线,可以沿方格边或者对角线画,给出要求圈出的面积,求最少需要多少根线
找到规律打一个表,多少根线最多可以围出的面积,然后二分去找下标。
这题还有点不懂,比如7根线可以围出5.5但怎么围出5?
#include <cstdio>#include <cstring>#include <algorithm>#define M 90000using namespace std;__int64 n;double a[M];void init(){ int i,I; for (i=4 ; i<M; i++) { I=i/4; if (i % 4 == 0) a[i] = I*I*2; else if ((i-1) % 4 == 0) a[i] = a[i-1]+I-0.5; else a[i] = a[i-1]+I+0.5; }}int main(){ init(); int T,i,j,f,r; scanf("%d", &T); while (T--) { scanf("%I64d", &n); printf("%d\n",lower_bound(a+4, a+M-1, n)-a); } return 0;}
阅读全文
0 0
- HDU 6154 CaoHaha's staff
- Hdu 6154 CaoHaha's staff
- HDU 6154 CaoHaha's staff
- HDU 6154 CaoHaha's staff
- HDU 6154 CaoHaha's staff
- hdu 6154 CaoHaha's staff
- hdu 6154 CaoHaha's staff
- HDU 6154 CaoHaha's staff
- HDU 6154 CaoHaha's staff
- hdu-CaoHaha's staff
- HDU 6154 CaoHaha's staff 找规律
- HDU 6154-CaoHaha's staff(ccpc)
- HDU 6154 CaoHaha's staff(规律)
- Hdu 6154 CaoHaha's staff【思维】
- HDU 6154 CaoHaha's staff【找规律】
- HDU 6154 CaoHaha's staff 找规律
- HDU 6154 CaoHaha's staff (数学)
- hdu 6154 CaoHaha's staff【找规律】
- Cause: java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timest
- GridLayout
- HDU6168-Numbers(离散|哈希)
- Flask实战2问答平台--导航条
- 封装成一个微信接口类
- HDU 6154 CaoHaha's staff
- 利用 caffe 接口构建 CNN 网络
- quartz定时任务之自定义注解实现动态配置任务
- 2017中国软件成本度量大会亮点提前看!
- 关于在git新建分支后IntelliJ IDEA不会自动刷新分支问题解决
- 小心情:继续未来的路
- idea maven多环境配置文件
- 发布的QT程序无法显示图标和图片的问题
- bootloader详解