Computer College Undergraduate Program Design contest (2015 ' 11) 1002 Coin Washing Machine

Source: Internet
Author: User
Tags ming first row
1002 Coin Washing Machine Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Problem Description Nowadays the living conditions of college students are getting better, recently, a university in Inner Mongolia has acquired a coin washing machine in every dormitory building.
Xiao Ming as a regular training in the ACM team, very Busy (Lan) Lu (Duo), of course, very happy to throw clothes to the washing machine solution. According to the number of clothes to be washed, the coin washing machine needs to put 2-4 coins each time.
Xiao Ming is a very easy to sweat boys, summer is coming, every day to bathe, so there are a large number of clothes need to wash.
Xiaoming is making the coin washing machine plan: When the amount of clothing is more than equals A and less than B, he would immediately wash the washing machine and put in 2 coins, and when the stocking quantity was greater than B and less than C, he would take it all to wash the washing machine and put in 3 coins. When the stocking quantity is greater than or equal to C, he will immediately take all the washing machine and put 4 coins. See examples for other details.

Now know, xiaoming past n days to change the number of clothes per day V, you need help to calculate the past time xiaoming spent washing clothes altogether how much money.

Input input contains multiple sets of test data.

The first row of each set of data is 4 positive integers n (1<=n<=10000), A, B, C (1&LT;=A&LT;B&LT;C&LT;=300), as described in the topic.

The second row of each set of data contains n positive integers, in order, the number of clothes produced in the past n days per day V (1<=v<=1000).

Output an integer for each set of data, indicating how much money the laundry service spent in the past n days.
One row for each set of outputs.

Sample Input
3 2 4 6 2 2 1
Sample Output
4

#include <stdio.h>
#include <stdlib.h>
int main ()
{
    int v,a,b,c,n,i,s=0,sum;
    while (~SCANF ("%d%d%d%d", &n,&a,&b,&c))
    {
        s=0;
        sum=0;
        For (i=0 i<n; i++)
        {
            scanf ("%d", &v);
            Sum+=v;
            if (sum>=c)
            {
                s+=4;
                sum=0;
            }
            else if (sum>=b)
            {
                s+=3;
                sum=0;
            }
            else if (sum>=a)
            {
                s+=2;
                Sum=0
            }
        }
        printf ("%d\n", s);
    }
    return 0;
}

Always looking at once space in a daze, those who say not separate friends, turn around, strangers. Familiar, quiet, quiet, left, left, unfamiliar, unfamiliar, disappeared, disappeared, strangers.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.