CaoHaha's staff(中国大学生程序选拔赛2017年网络大赛)
来源:互联网 发布:vue服务端渲染 php 编辑:程序博客网 时间:2024/05/16 06:27
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
分析:
纯粹找规律,从3个格子开始(前两个输出4),四个边一组,比如五条边为零(因为2是四条边,三六条边,五没有),然后六为2,七为1,八为3;之后四组则在原基础上加一。如下
5~89~1213~16012234123345#include<bits/stdc++.h>using namespace std;int a[4];int main(){ int t; cin>>t; while(t--) { int n; cin>>n; a[0]=0,a[1]=2,a[2]=1,a[3]=3; int sum=2,f=4; if(n<2) {cout<<4<<endl;continue;} else { while(sum<n) { for(int i=0;i<4;i++) { sum+=a[i]; a[i]++;f++; if(sum>=n) {break;} } } cout<<f<<endl; } }}
阅读全文
5 0
- CaoHaha's staff(中国大学生程序选拔赛2017年网络大赛)
- HDU-2017中国大学生程序设计竞赛-网络选拔赛-1005-CaoHaha's staff
- 2017中国大学生程序设计竞赛(网络选拔赛) HDU 6154 CaoHaha's staff
- 2017CCPC 网络选拔赛 1005 CaoHaha's staff
- 2017ccpc网络选拔赛 1005 CaoHaha's staff
- Friend-Graph(中国大学生程序选拔赛2017年网络大赛)
- 2017CCPC网络选拔赛1005CaoHaha's staff(规律贪心)
- hdu--6154--CaoHaha's staff(2017中国大学生程序设计竞赛
- HDU6154 CaoHaha's staff(规律,2017中国大学生程序设计竞赛
- CaoHaha's staff(规律,2017中国大学生程序设计竞赛
- 2017 ccpc网络预选赛 CaoHaha's staff
- 2017ccpc网络赛CaoHaha's staff
- 2017ccpc网络赛——CaoHaha's staff
- 2017CCPC网络赛1005 hdu6154 CaoHaha's staff
- 2017ccpc网赛-1005-CaoHaha's staff
- CaoHaha's staff
- HDU_6154 CaoHaha's staff
- CaoHaha's staff
- levelDB 的总结
- C++中 DWORD和int的区别
- Android Bitmap压缩图像的正确方法(compress的误区)
- Java+opencv3.2.0之重映射
- Java transient关键字使用小记
- CaoHaha's staff(中国大学生程序选拔赛2017年网络大赛)
- 傅立叶变换中的吉布斯(Gibbs)现象
- 朴素贝叶斯
- 【哈希查找】hashtable
- 前端开发必备软件/工具/学习网址
- 设计模式之原型模式
- 面试时遇到的一些题
- 层次遍历、递归:jump-game
- CCPC2017网络赛1005 CaoHaha's staff——找规律