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的序列,问说最少移动多少点,使得序列成等差序列,点的位置能够为小数. 解题思路:算是纯暴力吧.枚举等差的起始和 ...
随机推荐
- 初级模拟电路:3-1 BJT概述
回到目录 1. 名称由来 BJT的全称是双极性结型晶体管(Bipolar Junction Transistor),国内俗称三极管.其实,在英语中,三极管(triode)特指以前的真空电子管形式的 ...
- bootstrapValidator代码中开启验证和判断验证是否通过
//开启验证 $('#saveadmin_form').data('bootstrapValidator').validate(); //是否通过校验 if(!$('#saveadmin_form') ...
- API开发管理平台eoLinker AMS 4.1版本发布:加入聚合空间,发布AMS专业版等
eoLinker AMS是集API文档管理.API自动化测试.开发协作三位一体的综合API开发管理平台,是中国最大的在线API管理平台. eoLinker AMS 4.1更新内容: 1.新增" ...
- 字符串问题:去掉字符串中连续出现 k 个 0 的子串
[题目] 给定一个字符串 str 和 一个整数 k, 如果 str 中正好有连续 k 个 ‘0’ 字符出现时,把 k 个连续的 ‘0’ 字符去除,返回处理后的字符串. [举例] str="A ...
- c++ map: 当map的value是void*指针
#include <iostream> #include <map> #include <vector> using namespace std; //key is ...
- Linux内核同步:per_cpu变量
per cpu变量相关函数和宏 DEFINE_PER_CPU_SHARED_ALIGNED(type,name):静态分配per_cpu数组,数组名为name,结构类型为type DEFINE_PER ...
- LVM(Logical Volume Manager)逻辑卷管理
本文实验部分,完全由本人亲自动手实践得来 文章中有部分的内容是我个人通过实验测试出来的,虽以目前本人的能力还没发现不通之处,但错误难免,所以若各位朋友发现什么错误,或有疑惑.更好的建议等,盼请各位能在 ...
- Problem 30
Problem 30 https://projecteuler.net/problem=30 Surprisingly there are only three numbers that can be ...
- Spring整合Junit框架进行单元测试Demo
一.开发环境 eclipse版本:4.6.1 maven版本:3.3.3 junit版本:4.12 spring版本:4.1.5.RELEASE JDK版本:1.8.0_111 二.项目结构 图 三. ...
- 如何修改cnblogs的文本编辑器
我发现从别处复制过来的文本,文字上下间隔太大,所以我点击“html”标签,然后,把html内容复杂到记事本里,用记事本替换的功能,把“<p>”替换为“<p style="p ...