UVALive6969 ZOJ3819 Average Score

Source: Internet
Author: User

Regionals >> Asia-mudanjiang

Problem Link: UVALive6969 ZOJ3819 Average score. Basic training questions, written in C language.

Test instructions: There are n people in Bob's class (including Bob), and there are N people in the next class. If Bob is not in this class and joins the next class, the average of the two shifts will increase. Give Bob the n-1 individual scores and the next class M personal scores, ask Bob what the minimum and maximum value of the score.

Assuming Bob scores for X,bob and Suma, and for Sumb, the suma/(n-1) >= x >= sumb/(M + 1) must be met. Bob's results must be considered in the integer field, and the average score of the adjacent class is 1 points, which is 1 points less than the average of the class.

The following C language programs are adopted by AC:

/* UVALive6969 ZOJ3819 Average score */#include <stdio.h>int main (void) {    int t, n, M, Suma, Sumb, Val, Min, Max, i;    scanf ("%d", &t);    while (t--) {        scanf ("%d%d", &n, &m);        suma = 0;        for (I=1; i<=n-1; i++) {            scanf ("%d", &val);            Suma + = val;        }        Sumb = 0;        for (I=1; i<=m; i++) {            scanf ("%d", &val);            Sumb + = val;        }        Min = sumb/m + 1;        max = (suma% (n-1) = = 0)? Suma/(n-1)-1:suma/(n-1);        printf ("%d%d\n", Min, max);    }    return 0;}









UVALive6969 ZOJ3819 Average Score

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.