C——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
暗示、線索:[hint]Hint[/hint]
Gardon can buy 5=2+3,at most 2 flower, but he cannot buy 3 flower with 5 yuan.
###題目解析:
簡單來說:首先,多組數據輸入,有兩行,第一行有兩個整數,第二行數的個數不確定;
第一行的兩個整數:
第一個數代表:有幾種不同的價格的花
第二個數代表:Gardon 總共有多少錢
第二行的數是根據第一行的第一個數確定的,也就是說第二行是不同花的價格;
例如:
2 5 ———— 2代表著有2種不同價格的花;5代表著Gardon 總共有5美元
2 3 ————由于有2種不同價格的花,所以,第二行會有兩個數,分別表示2種不同的花的價格,一種是2美元,另一種是3美元
求Gardon 最多可以買多少只花?
###思路分析:
說白了,就是找到價格最便宜的花,讓Gardon 的錢數除以最便宜的花,取整,得出的結果就是要求的結果。
###代碼如下:
總結
以上是生活随笔為你收集整理的C——Flowers的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 卵泡监测多少钱啊?
- 下一篇: 地下城与勇士中如何提升公会等级?