UVALive6969 ZOJ3819 Average Score

Regionals 2014 >> Asia - Mudanjiang

问题链接:UVALive6969 ZOJ3819 Average Score。基础训练题,用C语言编写。

题意:Bob班里有n个人(包括Bob),邻班有n个人。若Bob不在本班,加入到邻班,两班的平均分都会增加。给出Bob班里n-1个人的分数以及邻班m个人的分数,问Bob分数可能的最小值和最大值是多少。

假设Bob分数为x,Bob班分数和为suma,邻班分数和为sumb,则必须满足suma/(n-1) >= x >= sumb/(m + 1)。Bob的成绩必须在整数域中进行考虑,比邻班平均成绩的要多1分,比本班的平均成绩要少1分。

AC通过的C语言程序如下:

/* 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;
}
时间: 2024-08-06 09:35:33

UVALive6969 ZOJ3819 Average Score的相关文章

ZOJ3819 ACM-ICPC 2014 亚洲区域赛的比赛现场牡丹江司A称号 Average Score 注册标题

Average Score Time Limit: 2 Seconds      Memory Limit: 131072 KB Bob is a freshman in Marjar University. He is clever and diligent. However, he is not good at math, especially in Mathematical Analysis. After a mid-term exam, Bob was anxious about his

2014ACM/ICPC亚洲区域赛牡丹江站现场赛-A ( ZOJ 3819 ) Average Score

Average Score Time Limit: 2 Seconds      Memory Limit: 65536 KB Bob is a freshman in Marjar University. He is clever and diligent. However, he is not good at math, especially in Mathematical Analysis. After a mid-term exam, Bob was anxious about his

ZOJ 2819 Average Score 牡丹江现场赛A题 水题/签到题

ZOJ 2819 Average Score Time Limit: 2 Sec  Memory Limit: 60 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 Description Bob is a freshman in Marjar University. He is clever and diligent. However, he is not good at math, especia

ZOJ 3819 Average Score 水

水 Average Score Time Limit: 2 Seconds      Memory Limit: 65536 KB Bob is a freshman in Marjar University. He is clever and diligent. However, he is not good at math, especially in Mathematical Analysis. After a mid-term exam, Bob was anxious about hi

zoj 3819 Average Score

Average Score Time Limit: 2 Seconds      Memory Limit: 65536 KB Bob is a freshman in Marjar University. He is clever and diligent. However, he is not good at math, especially in Mathematical Analysis. After a mid-term exam, Bob was anxious about his

[ACM] ZOJ 3819 Average Score (水题)

Average Score Time Limit: 2 Seconds      Memory Limit: 65536 KB Bob is a freshman in Marjar University. He is clever and diligent. However, he is not good at math, especially in Mathematical Analysis. After a mid-term exam, Bob was anxious about his

ZOJ 3819 Average Score (精度处理)

题目链接:ZOJ 3819 Average Score 题意:给出A班和B班的学生成绩,如果bob(A班的)在B班的话,两个班级的平均分都会涨.求bob成绩可能的最大,最小值. A班成绩平均值(不含BOB)>A班成绩平均值(含BOB) &&  B班成绩平均值(不含BOB)< B班成绩平均值(含BOB) 求解两个不等式,注意精度 AC代码: #include <stdio.h> int main() { int t; int i,n,m; double a[100],

ZOJ 3819 Average Score(平均分)

[题目描述] English 中文 Bob is a freshman in Marjar University. He is clever and diligent. However, he is not good at math, especially in Mathematical Analysis. After a mid-term exam, Bob was anxious about his grade. He went to the professor asking about t

ZOJ 3819 Average Score(数学题 牡丹江)

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 Bob is a freshman in Marjar University. He is clever and diligent. However, he is not good at math, especially in Mathematical Analysis. After a mid-term exam, Bob was anxious about