本题的难点是可以在y轴正轴动,但也是突破点,知道x轴都是整数,那么对于任意长度来说,能到达的最短是1,最长是本身长度,那么我们就选择最长的距离,跳到一个点,使这个点为再跳就超过终点,那么就可以用2次跳跃到达终点,那么我们可以对终点距离/最大跳跃距离向上取整,与2的最大值为ans,除非一步可以到

#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long LL; void run_case() {
LL n, x, tmp, Max=-;
bool flag = true;
cin >> n >> x;
for(int i = ; i < n; ++i) {
cin >> tmp;
if(tmp == x) {
flag = false;
}
Max = max(Max, tmp);
}
if(flag)
cout << max((LL)ceil((double)x/Max), 2LL) << "\n";
else cout << "1\n";
} int main() {
ios::sync_with_stdio(false), cin.tie();
//cout.setf(ios_base::showpoint);cout.precision(10);
int t; cin >> t;
while(t--)
run_case();
cout.flush();
return ;
}

Codeforces1307B. Cow and Friend的更多相关文章

  1. POJ 3278 Catch That Cow(bfs)

    传送门 Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 80273   Accepted: 25 ...

  2. 【BZOJ1623】 [Usaco2008 Open]Cow Cars 奶牛飞车 贪心

    SB贪心,一开始还想着用二分,看了眼黄学长的blog,发现自己SB了... 最小道路=已选取的奶牛/道路总数. #include <iostream> #include <cstdi ...

  3. HDU Cow Sorting (树状数组)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2838 Cow Sorting Problem Description Sherlock's N (1  ...

  4. [BZOJ1604][Usaco2008 Open]Cow Neighborhoods 奶牛的邻居

    [BZOJ1604][Usaco2008 Open]Cow Neighborhoods 奶牛的邻居 试题描述 了解奶牛们的人都知道,奶牛喜欢成群结队.观察约翰的N(1≤N≤100000)只奶牛,你会发 ...

  5. 细读cow.osg

    细读cow.osg 转自:http://www.cnblogs.com/mumuliang/archive/2010/06/03/1873543.html 对,就是那只著名的奶牛. //Group节点 ...

  6. POJ 3176 Cow Bowling

    Cow Bowling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13016   Accepted: 8598 Desc ...

  7. raw,cow,qcow,qcow2镜像的比较

    在linux下,虚拟机的选择方式有很多,比如vmware for linux,virtual box,还有qemu,在以前,使用qemu的人不多,主要是使用起来有些麻烦,但现在随着Openstack的 ...

  8. poj1985 Cow Marathon (求树的直径)

    Cow Marathon Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 3195   Accepted: 1596 Case ...

  9. (01背包变形) Cow Exhibition (poj 2184)

    http://poj.org/problem?id=2184   Description "Fat and docile, big and dumb, they look so stupid ...

随机推荐

  1. list-style: none;

    表明list项前面没有什么修饰(一片空白).

  2. python小白的爬虫之旅

    1.爬www.haha56.net/main/youmo网站的内容 ieimport requests import re response=requests.get("http://www ...

  3. java篇 之 静态

    Final:不可改变 Static:静态修饰符,在编译阶段就能确定了,可以修饰成员变量,相应的称之为静态变量 是一个共享的变量(被这个类和这个类所产生的对象所共享的,他是唯一的,出生时间 为类第一次产 ...

  4. AMD R7 2700X 安装虚拟机

    自己组装的台式机,选用的是微星X470主板,该主板默认的虚拟化技术是关闭的,在bios中也不太容易找到,具体方法如下. [开机或重启]--[按住DEL进入BIOS]--[高级模式F7]--[选择OC] ...

  5. 【Hibernate 多表查询】

    HibernateManyTable public class HibernateManyTable { //演示hql左连接查询 @Test public void testSelect12() { ...

  6. idea抽取方法

    问题:有时候一个方法里面嵌套了很多逻辑,想拆分为多个方法方便调用:或者一个方法复用性很高,这时,这个方法嵌套在局部方法里面肯定是不方便的,如何快速抽取出这个方法? public class Demo ...

  7. vagrant up 报VirtualBox错误

    Debug output $ $ vagrant.exe up ==> default: Checking if box 'janihur/ubuntu-1404-desktop' is up ...

  8. WLC-生成CSR操作

    1.生成CSR [req]req_extensions = v3_req[ v3_req ]# Extensions to add to a certificate requestbasicConst ...

  9. selected中第一项 请选择,隐藏

    如何做到selected 类似input的提示语  placeholder效果. <select class="wyj_dbfs"> <option style= ...

  10. Linux中制作静态库

    静态库生成: 1.第一步:生成.o文件 2.第二步:将所有.o文件打包 ar src  libMyTest.a  *.o 生成出libMyTest.a 3.使用: 第一种:gcc  main.c    ...