HDU 6154 CaoHaha's staff
来源:互联网 发布:qq管家软件管理 编辑:程序博客网 时间:2024/06/05 10:17
CaoHaha's staff
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 677 Accepted Submission(s): 400
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
Source
2017中国大学生程序设计竞赛 - 网络选拔赛
Recommend
liuyiding
题意:一个每个格子都是面积为1 的 网格中, 围出面积 n需要多少条线。
分析:
画图可以找到规律。
AC代码:
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;double ans[100000];int main(){ ans[4]=2.0,ans[5]=2.5,ans[6]=4.0; long long f1=1,f2=1,cnt=0; double p1=1.5,p2=2.5; for(int i=7;ans[i-1]<=1e9;i++) {ans[i]=ans[i-1];if(i%2){ ans[i]+=p1; f1++; if(f1%2) p1++;}else{ ans[i]+=p2; f2++; if(f2%2)p2++;}cnt++; } int T; scanf("%d",&T); while(T--) {double n;scanf("%lf",&n);int p=lower_bound(ans+4,ans+4+cnt,n)-ans;printf("%d\n",p); }}
阅读全文
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【找规律】
- 分布式系统介绍
- tf.unstack的作用
- setitimer和sigaction函数写的每隔5秒在循环屏幕打印hello world
- opencv中头文件详解
- C语言结构体数组同时赋值的另类用法
- HDU 6154 CaoHaha's staff
- python mysql 模糊查询
- Serializable接口
- Hive的高级聚合函数
- Cordova开发环境搭建
- 科大讯飞手写识别
- 这是一篇用测试MetaAPI的测试内容2
- 树-堆结构练习——合并果子之哈夫曼树(优先队列)
- 膜法师【NOIP提高组模拟A组8.15】