HDU6154CaoHaha's staff(递推+网格)
来源:互联网 发布:美萍美容美发软件 编辑:程序博客网 时间:2024/05/21 19:50
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long LL;const int maxn=1e6+5;/*递推+网格题意:在笛卡尔坐标系下,画一个面积至少为n的简单多边形,每次只能画一条边或者一个格子的对角线,问至少要画几条。规律:笔画 4 5 6 7 8 9 10 11 12 13 14 15 16面积 2 2.5 4 5.5 8 9.5 12 14.5 18 20.5 24 27.5 32*/double a[maxn];int n;void init(){ a[4]=2; a[5]=2.5; a[6]=4; double u=4;//初始化差值 double v=1.5; for(int i=7;i<=maxn;i++) { int k=i%4; if(k==1)//增加的面积比前一次多1 { a[i]=a[i-1]+v; v+=1.0; } if(k==2)//增加的面积比前一次多2 { a[i]=a[i-2]+u; u+=2; } if(k==3)//增加的面积和前面一次相同 { a[i]=a[i-1]+v; } if(k==0)//增加的面积和前面一次相同 { a[i]=a[i-2]+u; } }}int main(){ int t; init(); scanf("%d",&t); while(t--) { scanf("%d",&n); int ans=lower_bound(a,a+maxn,n)-a; printf("%d\n",ans); } return 0;}
阅读全文
0 0
- HDU6154CaoHaha's staff(递推+网格)
- hdu6154CaoHaha's staff(打表找规律)
- hdu6154CaoHaha's staff
- hdu6154CaoHaha's staff(2017网络赛规律)
- CaoHaha's staff(hdoj6154)
- HDU 6154-CaoHaha's staff(ccpc)
- HDU 6154 CaoHaha's staff(规律)
- hdu6154-CaoHaha's staff(找规律)
- HDU 6154 CaoHaha's staff (数学)
- 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(找规律)
- HDU 6154 CaoHaha's staff(找规律)
- HDU 6154 CaoHaha's staff(【数学规律题】)
- Android RemoteCallbackList类
- 读书笔记_C#入门经典(第5版)第六章_函数
- onSaveInstanceState、onRestoreInstanceState、onNewIntent调用时机
- JAVA学习笔记_断言的使用
- 【POJ1113】【计算几何】Wall 题解
- HDU6154CaoHaha's staff(递推+网格)
- bzoj2440(二分+莫比乌斯函数)
- angular.js框架简单实现加载无限加载商品
- 如何把UCos-ii_在STM32上的移植
- selenium IDE 资源整理
- 第七篇:设计模式六大原则: 辅导班的因材施教 -- 接口隔离原则
- 第20天
- UCOS-II移植ARM的笔记
- linux 下 安装mysql