HDOJ(HDU) 1587 Flowers(水、、)
Problem Description
As you know, Gardon trid hard for his love-letter, and now he’s spending too much time on choosing flowers for Angel.
When Gardon entered the flower shop, he was frightened and dazed by thousands kinds of flowers.
“How can I choose!” Gardon shouted out.
Finally, Gardon– a no-EQ man decided to buy flowers as many as possible.
Can you compute how many flowers Gardon can buy at most?
Input
Input have serveral test cases. Each case has two lines.
The first line contains two integers: N and M. M means how much money Gardon have.
N integers following, means the prices of differnt flowers.
Output
For each case, print how many flowers Gardon can buy at most.
You may firmly assume the number of each kind of flower is enough.
Sample Input
2 5
2 3
Sample Output
2
HintHint
Gardon can buy 5=2+3,at most 2 flower, but he cannot buy 3 flower with 5 yuan.
大概题意:
输入m n
再输入m种花的价格
就是你有n元钱,需要买最多的花,问最多能买多少朵花!
一种花你可以买很多朵!!!
所以,只要找到最低价格的花就可以了。
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int a = sc.nextInt();
int b = sc.nextInt();
int min = sc.nextInt();
a--;
int t;
while(a-->0){
t = sc.nextInt();
if(t<min){
min=t;
}
}
System.out.println(b/min);
}
}
}
HDOJ(HDU) 1587 Flowers(水、、)的更多相关文章
- hdu 1587 Flowers
Flowers Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...
- HDOJ(HDU) 1718 Rank(水题、、、)
Problem Description Jackson wants to know his rank in the class. The professor has posted a list of ...
- HDU 1587 Flowers【贪心】
题意:给出n种花的价钱,和总的金额m,问最多能够买到多少朵花.先排序,然后就是便宜的花在能够买的范围内能够多买就多买 #include<iostream> #include<cstd ...
- HDOJ(HDU).1058 Humble Numbers (DP)
HDOJ(HDU).1058 Humble Numbers (DP) 点我挑战题目 题意分析 水 代码总览 /* Title:HDOJ.1058 Author:pengwill Date:2017-2 ...
- HDU 4325 Flowers 树状数组+离散化
Flowers Problem Description As is known to all, the blooming time and duration varies between differ ...
- HDOJ(HDU).1412 {A} + {B} (STL SET)
HDOJ(HDU).1412 {A} + {B} (STL SET) 点我挑战题目 题意分析 大水题,会了set直接用set即可. 利用的是set的互异性(同一元素有且仅有一项). #include ...
- HDOJ(HDU).1754 I Hate It (ST 单点替换 区间最大值)
HDOJ(HDU).1754 I Hate It (ST 单点替换 区间最大值) 点我挑战题目 题意分析 从题目中可以看出是大数据的输入,和大量询问.基本操作有: 1.Q(i,j)代表求区间max(a ...
- HDOJ(HDU).1166 敌兵布阵 (ST 单点更新 区间求和)
HDOJ(HDU).1166 敌兵布阵 (ST 单点更新 区间求和) 点我挑战题目 题意分析 根据数据范围和询问次数的规模,应该不难看出是个数据结构题目,题目比较裸.题中包括以下命令: 1.Add(i ...
- HDOJ(HDU).2844 Coins (DP 多重背包+二进制优化)
HDOJ(HDU).2844 Coins (DP 多重背包+二进制优化) 题意分析 先把每种硬币按照二进制拆分好,然后做01背包即可.需要注意的是本题只需要求解可以凑出几种金钱的价格,而不需要输出种数 ...
随机推荐
- iOS8 Core Image In Swift:视频实时滤镜
iOS8 Core Image In Swift:自己主动改善图像以及内置滤镜的使用 iOS8 Core Image In Swift:更复杂的滤镜 iOS8 Core Image In Swift: ...
- HDU 1166 敌兵布阵(线段树)
题目地址:pid=1166">HDU 1166 听说胡浩版的线段树挺有名的. 于是就拜訪了一下他的博客.详情戳这里.于是就全然仿照着胡浩大牛的风格写的代码. 至于原理.鹏鹏学长已经讲的 ...
- STL之set && multiset
一.set 在了解关联容器set之前,让我们先来看看下面这个例子,并猜测该例子输出什么: // stl/set1.cpp #include <iostream> #include < ...
- 线程在WPF中的使用
项目中可能会有这样的需求,一直获取新的某个数据信息,但仍不影响其他的操作功能,这时就用到了线程,获取新数据放到线程中操作,对其他操作不产生影响,下面就以随机获取数组中项为例解说WPF中使用线程这一实例 ...
- exploit writing tutorial 阅读笔记总结
近日阅读Corelan Team编写的exploit writing tutorial系列,大致了解了一下原理,记了一些笔记.此系列文章有中文翻译版,在看雪论坛上发表. 英文版地址:https://w ...
- 菜鸟学习Ado.net笔记一:Ado.net学习之SqlHelper类
using System; using System.Collections.Generic; using System.Text; using System.Data.SqlClient; usin ...
- .Net程序员 Solr-5.3之旅 (三)Solr 从MSSQ导入索引数据
阅读目录 引言 准备工作 data-config.xml schema.xml 导入数据 结尾 附件下载 引言 Other men live to eat, while I eat to live.- ...
- chrome Provisional headers are shown错误提示
1.一般出现这个错误是请求没有发送成功 可能原因:在上传文件或ajax上传时指定的timeout,过时时间小 其他资料: http://www.duanzhihe.com/575.html http: ...
- oracle 中 group by 加强
group by rollup(a,b) = group by a,b + group by a + group by null SQL> select deptno,job,sum(sal) ...
- 《Linux内核分析》 week5作业-system call中断处理过程
一.使用gdb跟踪分析一个系统调用内核函数 1.在test.c文件中添加time函数与采用c语言内嵌汇编的time函数.具体实现请看下图. 2.然后在main函数中添加MenuConfig函数,进行注 ...