D - Garden
Problem description
Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly ai each hour. Luba can't water any parts of the garden that were already watered, also she can't water the ground outside the garden.
Luba has to choose one of the buckets in order to water the garden as fast as possible (as mentioned above, each hour she will water some continuous subsegment of length ai if she chooses the i-th bucket). Help her to determine the minimum number of hours she has to spend watering the garden. It is guaranteed that Luba can always choose a bucket so it is possible water the garden.
See the examples for better understanding.
Input
The first line of input contains two integer numbers n and k (1 ≤ n, k ≤ 100) — the number of buckets and the length of the garden, respectively.
The second line of input contains n integer numbers ai (1 ≤ ai ≤ 100) — the length of the segment that can be watered by the i-th bucket in one hour.
It is guaranteed that there is at least one bucket such that it is possible to water the garden in integer number of hours using only this bucket.
Output
Print one integer number — the minimum number of hours required to water the garden.
Examples
Input
3 6
2 3 5
Output
2
Input
6 7
1 2 3 4 5 6
Output
7
Note
In the first test the best option is to choose the bucket that allows to water the segment of length 3. We can't choose the bucket that allows to water the segment of length 5 because then we can't water the whole garden.
In the second test we can choose only the bucket that allows us to water the segment of length 1.
解题思路:题目的意思就是有n个桶,选择其中一个长度为a(每小时可以浇的长度为a)的桶,使得刚好浇完长度为k的花园,要求浇过的不能再浇,求全程最短用时。结合提示可以知道,要刚好浇完长度为k的花园,必须选择a刚好被k整除的桶,这样最后才不会有重叠,并且a在所有桶长度中是k的较大因子,这样全程用时才最短。
AC代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,k,x,mt=;
cin>>n>>k;
while(n--){
cin>>x;
if(k%x==)mt=min(mt,k/x);//取最短时间
}
cout<<mt<<endl;
return ;
}
D - Garden的更多相关文章
- HDU5977 Garden of Eden(树的点分治)
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5977 Description When God made the first man, he ...
- hdu-5977 Garden of Eden(树分治)
题目链接: Garden of Eden Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/ ...
- nginx+iis、NLB、Web Farm、Web Garden、ARR
nginx+iis实现负载均衡 在win2008R2上使用(NLB)网络负载均衡 NLB网路负载均衡管理器详解 [译文]Web Farm和Web Garden的区别? IIS负载均衡-Applicat ...
- uva10001 Garden of Eden
Cellular automata are mathematical idealizations of physical systems in which both space and time ar ...
- CF459A Pashmak and Garden (水
Pashmak and Garden Codeforces Round #261 (Div. 2) A. Pashmak and Garden time limit per test 1 second ...
- ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 G. Garden Gathering
Problem G. Garden Gathering Input file: standard input Output file: standard output Time limit: 3 se ...
- Web Farm 和Web Garden
这两个都是提高网站性能的服务器端技术 1.Web Farm:如果应用程序被多个服务器托管,这种情况就可以称作Web Farm. 2.Web Garden: 指的是一个应用程序可以分成多个进程(w3wp ...
- Web Farm和Web Garden的区别
在这篇博文中,我将确切剖析Web Farm和Web Garden的区别和原理,以及使用它们的利弊.进一步地,我将介绍如何在各个版本的IIS中创建Web Garden. 英文原文 | Abhijit J ...
- cf459A Pashmak and Garden
A. Pashmak and Garden time limit per test 1 second memory limit per test 256 megabytes input standar ...
- bnu 34982 Beautiful Garden(暴力)
题目链接:bnu 34982 Beautiful Garden 题目大意:给定一个长度为n的序列,问说最少移动多少点,使得序列成等差序列,点的位置能够为小数. 解题思路:算是纯暴力吧.枚举等差的起始和 ...
随机推荐
- 【转】关于JMeter线程组中线程数,Ramp-Up Period,循环次数之间的设置概念
关于JMeter线程组中线程数,Ramp-Up Period,循环次数之间的设置概念 笔者是个刚刚踏入压力测试领域不到2个月的小菜,这里分享一下线程组中3个参数之间关系的个人见解,不喜请!喷!,望大家 ...
- PHP常用的设计模式
工厂模式 工厂模式是我们最常用的实例化对象模式,是用工厂方法代替new操作的一种模式. 使用工厂模式的好处是如果你想要更改所实例化的类名等,则只需要更改该工厂方法内容即可,不需逐一寻找代码中具体实例化 ...
- MongoDB - 认识MongoDB及数据类型
目录 MongoDB - 认识MongoDB及数据类型 启动 MogoDB的数据 MogoDB的数据类型 1.Object ID : Documents自生成的_id 2.string : 字符串,必 ...
- 第十三节:pandas之groupby()分组
1.Series()对象分组 1.1.单级索引 1.2.多级索引 2.DataFrame()对象分组 3.获取一个分组,遍历分组,filter过滤.
- NLTK学习笔记(七):文本信息提取
目录 实体识别:分块技术 分块语法的构建 树状图 IOB标记 开发和评估分块器 命名实体识别和信息提取 如何构建一个系统,用于从非结构化的文本中提取结构化的信息和数据?哪些方法使用这类行为?哪些语料库 ...
- mysql的一些高级查询
1,查出学生详情表性别为男,并同时年龄大于18的 2,根据上述的结果,查出学生表对应的姓名,年龄,性别,address 3,查出学生的(姓名,年龄,性别,所属学院) 还可以添加注释
- eventlet学习笔记
eventlet学习笔记 标签(空格分隔): python eventlet eventlet是一个用来处理和网络相关的python库函数,且可以通过协程(coroutines)实现并发.在event ...
- HDU 4508
祼的完全背包问题 #include <iostream> #include <cstdio> #include <cstring> #include <alg ...
- 阿伦 凯 Alan Kay 面向对象编程思想创始人
The best way to predict the future is to invent it. 预测未来最好的办法就是创造它.
- springmvc mybatis 分页插件 pagehelper
springmvc mybatis 分页插件 pagehelper 下载地址:pagehelper 4.2.1 , jsqlparser 0.9.5 https://github.com/pagehe ...