Answers to ACM platform questions of Shandong University of Technology about C language 1242 even sum

Source: Internet
Author: User

Even sum Time Limit: 1000 ms Memory limit: 65536 K any questions? Click Here ^_^ The topic description contains a series of n (n <= 100). The sequence is defined as an ascending, ordered, and even number starting from 2. Now, you need to obtain an average value for each m number in order, if there are less than m at last, calculate the average value based on the actual quantity. Program the output of the average value sequence. There are multiple groups of input data. Each group occupies one row and contains two positive integers n, m, n, and m. For each group of input data, an average value sequence is output, and each group of output occupies one row. Sample Input
3 24 2
Sample output
3 63 7
 
 
# Include
Void main ()
{
Int a, l, I, j, m, n, t;
Long int c, B, r;
While (scanf ("% d", & m, & n )! = EOF)
{

If (m % n = 0)
{
R = m/n; a = 2;
For (I = 1; I <= r; I ++)
{B = 0;
For (j = 0; j {B + = a; a = a + 2;

}
C = B/n;
If (I! = R)
Printf ("% ld", c );
Else
Printf ("% ld", c );
} Printf ("\ n ");
}
Else
{
R = m/n; l = m-n * r; t = 2;
For (I = 1; I <= r; I ++)
{
B = 0;
For (j = 0; j {
B + = t;
T = t + 2;
}
C = B/n;
Printf ("% ld", c );
}
B = 0;
For (I = 1; I <= l; I ++)
{
B + = t; t = t + 2 ;}
C = B/l;
Printf ("% ld \ n", c );
}
}

}

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.