The contest summarizes the ———————————— the national freshman race.

Source: Internet
Author: User

—————————————————————————————————————— 1002 ————————————————————————————

Coin Laundry Time Limit: -/ +MS (java/others) Memory Limit:32768/32768K (java/Others) Total submission (s):5878Accepted Submission (s):1460problem Description Now college students living conditions more and more good, recently, a university in Inner Mongolia in each dormitory building has bought a coin washing machine. Xiao Ming as a regular training of ACM players, very Busy (Lan) (Duo), of course, very happy to throw clothes to the washing machine to solve. Depending on the number of clothes to be washed, the coin washer needs to invest 2 each time-4coin.  Xiao Ming is a very easy to sweat boys, summer is coming, every day to bathe, so there is a lot of clothes need to wash. Xiao Ming is making a coin washing machine plan: When the number of stocking clothes is greater than or equal to a and less than B, he will immediately all take to wash the washing machine, and put in 2 coins; when stocking's clothing quantity is greater than or equal to B and less than C, he will immediately all take to wash the washing machine, and put in 3 coins When the number of clothes in stocking is greater than or equal to C, he will immediately be taken to wash the washing machine and put in 4 coins.  See examples for other details. Now know, xiaoming in the past n days to change the number of clothes per day V, you need to help calculate how Xiao Ming in the past time to wash clothes spent a total of money. Input inputs contain multiple sets of test data. The first row of each group of data is 4 positive integer n (1<=n<=10000), A, B, C (1<=a<b<c<= -), the specific meaning is described in the topic. The second row of each set of data contains n positive integers, sequentially representing the number of garments produced per day in the past N days V (1<=v<= +). Output each set of data outputs an integer that indicates how much money the laundry has spent in the past n days. One row for each set of outputs. Sample Input3 2 4 62 2 1Sample Output4

The subject is a water problem.

First give me the wrong answer: I do not know is because of the pressure of tension or something, the wrong is so serious. Where the code and the error are attached

#include <stdio.h>intMain () {inta,b,c,i,n,m;  while(SCANF ("%d%d%d%d", &n,&a,&b,&c)! =EOF) {        intq=0, s=0;  for(i=0; i<n;i++) {scanf ("%d",&m); M=m+q;//Q will have to be 0 after the end of this use. When a variable goes through a loop, hold on to the number that he should be.             if(m>=a&&m<b) S=s+2; Else                if(m>=b&&m<c) S=s+3; Else                    if(m>=4) s=s+4; ElseQ=q+m;//here the q=q+m and above the M=m+q, a match is just m=2*m+q; dead force;                    if(q>=a)//here is purely nonsense, do not know how to think of this, the reason should be the function of their own calls with a few. {s=s+q;//There is no need for an if judgment. q=0; }} printf ("%d\n", s); }}

The revised code is attached below.

#include <stdio.h>intMain () {inta,b,c,i,n,v;  while(SCANF ("%d%d%d%d", &n,&a,&b,&c)! =EOF) {        intq=0, s=0;  for(i=0; i<n;i++) {scanf ("%d",&v); V=v+Q; Q=0; if(v>=a&&v<b) S=s+2; Else                if(v>=b&&v<c) S=s+3; Else                    if(v>=c) S=s+4; ElseQ=v; } printf ("%d\n", s); S=0; }}

Not discouraged, as long as you are in other people's sleep when learning, others learn more efforts to study. You'll be able to kill them. Up and up!!!

The contest summarizes the ———————————— the national freshman race.

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.