hdu6154CaoHaha's staff(打表找规律)
来源:互联网 发布:pace.js 在线演示 编辑:程序博客网 时间:2024/06/05 22:48
题意:
给你n,让你在坐标系上画多边形,使得其面积大于等于n,输出最少的边数,边的长度可以为1或者根号2(对角)。
思路:
画前十几条边能凑的最大面积,然后找规律就好,比赛的时候只找出了偶数边的规律,奇数边没找到(只要那个7条边画出面积为5当时怎么也画不出来···,后来明白不能只能在一个方向上扩展边,要对称的扩展边,,=。=!)
代码:
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <queue>#include <vector>#include <map>#include <set>#include <cstdlib>#include <cmath>using namespace std;typedef long long ll;const ll INF = 0x3f3f3f3f;const ll INFF = 0x3f3f3f3f3f3f3f3f;const double inf = 1e18;const double eps = 1e-8;const ll mod = 1e9+7;double arr[1000005];int main(){ arr[4] = 2; arr[5] = 2.5; arr[6] = 4; double tmp = 4; int flag = 0; int i = 6; while(arr[i]<INF) { arr[i+2] = arr[i]+tmp; if(flag==1) { tmp+=2; flag = 0; } else flag = 1; i += 2; } tmp = 3; i = 5; while(arr[i]<INF) { arr[i+2] = arr[i]+tmp; tmp++; i += 2; } int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int ans = lower_bound(arr,arr+100005,n)-arr; printf("%d\n",ans); } return 0;}
阅读全文
1 0
- hdu6154CaoHaha's staff(打表找规律)
- hdu6154CaoHaha's staff(2017网络赛规律)
- HDU6154CaoHaha's staff(递推+网格)
- hdu6154CaoHaha's staff
- HDU 6154 CaoHaha's staff(规律)
- hdu6154-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 【规律打表】
- 【HDU6154】CaoHaha's staff (二分+规律)
- HDU6154 CaoHaha's staff 找规律|签到
- hdu6154 CaoHaha's staff 找规律
- HDU 6154 CaoHaha's staff【找规律】
- HDU 6154 CaoHaha's staff 找规律
- hdu 6154 CaoHaha's staff【找规律】
- CCPC网赛 CaoHaha's staff(找规律+模拟扩展正方形)
- 百度之星复赛--Pokémon GO----dp
- AngularJs+bootstrap搭载前台框架——准备工作
- 到底是 Activity 被回收了还是进程被杀死了?
- iscsi共享设备
- ZeroClipboard 不支持手机浏览器复制 H5页面的几种复制方式分享
- hdu6154CaoHaha's staff(打表找规律)
- 【POJ 2528】Mayor's posters(线段树,离散化)
- PtQt4标准对话框——QFileDialog
- mysql:InnoDB的主键采用聚簇索引,二级索引不采用聚簇索引
- 如何将一个列表嵌套的结构中的每个最底层元素取出,并形成一个新的列表
- 第二章:2.6 LTI系统特性与单位冲击信号的关系
- 【Hibernate】简单集合映射
- QT C++对象不用手动delete的条件
- 编写DAOImpl的JUnit测试