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],b[100];
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d",&n,&m);
        double sum1,sum2,ave1,ave2;
        int ans1,ans2;
        sum1=sum2=0;
        for(i=0;i<n-1;i++)
        {
            scanf("%lf",&a[i]);
            sum1+=a[i];
        }
        for(i=0;i<m;i++)
        {
            scanf("%lf",&b[i]);
            sum2+=b[i];
        }
        ave1=sum1/(n-1);//没bob的自己班
        ave2=sum2/m;//没bob的其他班
        double temp1=ave1*n-sum1;
        double temp2=ave2*(m+1)-sum2;
        if((int)temp1*1.0==temp1)
            ans1=(int)temp1-1;
        else
             ans1=(int)temp1;
        ans2=(int)temp2+1;
        printf("%d %d\n",ans2,ans1);
    }
return 0;
}
时间: 2024-10-12 09:19:33

ZOJ 3819 Average Score (精度处理)的相关文章

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(平均分)

[题目描述] 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

ZOJ 3819 Average Score(数学 牡丹江游戏网站)

主题链接:problemId=5373">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, Bo

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(牡丹江现场赛A题)

马上要去上海了,刷刷现场赛的题找找感觉~~~ 这题.......额,没什么好说的,太水.. ZOJ Problem Set - 3819 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 Mat

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