CaoHaha's staff
来源:互联网 发布:tscttp244plus软件 编辑:程序博客网 时间:2024/05/29 17:15
CaoHaha's staff
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2089 Accepted Submission(s): 818
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
一道找规律的题,画图都画了老半天。。特别是5格7边花了半天才发现可以画一个5.5格的,分奇偶找通项公式,预处理,二分求答案
#include<cstdio>#include<cstring>#include<cmath>#include<iostream>#include<algorithm>using namespace std;int a[500010]={0,0,0,0};int main(){ for(int i=4;i<=100000;i++){ if(i%2==0){ int k=i%4; k=k/2; a[i]=2*(i/4)*(i/4+k); } else{ int k=(i-1)%4; k=k/2; a[i]=a[i-1]+(i-1)/4+k-0.5; } } int t; scanf("%d",&t); while(t--){ long long n,x; scanf("%lld",&n); x=lower_bound(a,a+100000,n)-a; printf("%lld\n",x); }}
阅读全文
0 0
- CaoHaha's staff
- HDU_6154 CaoHaha's staff
- CaoHaha's staff
- HDU6154-CaoHaha's staff
- hdu-CaoHaha's staff
- hdu6154 CaoHaha's staff
- HDU 6154 CaoHaha's staff
- CaoHaha's staff(hdoj6154)
- 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
- hdoj 6154 CaoHaha's staff
- hdu-6156 CaoHaha's staff
- HDU 6154 CaoHaha's staff
- HDU 6154 CaoHaha's staff
- a标签中href=""的几种用法
- js中加“var”和不加“var”的区别
- Python2.7+Python3.5(win10)双版本环境配置
- POJ
- JavaScript闭包详解
- CaoHaha's staff
- Java 并发 ---AbstractQueuedSynchronizer-共享模式与Condition
- Android Studio Debug Android Open Source Project
- hdu6113 度度熊的01世界
- 快速排序的实现与使用
- 网络爬虫相关知识点
- 嵌套类:静态嵌套类和非静态嵌套类
- ubuntu安装最新版本mysql
- 使用scikit-image包的io模块导入图片