HDU 1587 Flowers

    xiaoxiao2025-08-05  19

    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 Gardon can buy 5=2+3,at most 2 flower, but he cannot buy 3 flower with 5 yuan.

    题意:输入第一个数字是下列有多少种花,第二个数字是现有的总钱数。下列列出每种花的价格。问总共能买多少朵花。

    首先我要说的就是,最后那个提示内容就是坑,叫误导内容更贴切。5元可以买一朵2元和一朵3元的,同时也可以都买2元的。上列只是每种花的价格,每种有多少朵没有限制。所以要想买最多只买最便宜的就行。

    不用排序,开始排了就懒得改了。

    #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int a[10000000]; int main() { int n,m,i; while(~scanf("%d%d",&n,&m)) { for(i=0;i<n;i++) { scanf("%d",&a[i]); } sort(a,a+n); int sum; sum=m/a[0]; printf("%d\n",sum); } return 0; }

    转载请注明原文地址: https://ju.6miu.com/read-1301416.html
    最新回复(0)