SubmitStatusPracticeHDU 4968

来源:互联网 发布:数据统计与分析方法 编辑:程序博客网 时间:2024/06/11 05:38
 
J - 。。。。。。。。。。
Time Limit:1000MS    Memory Limit:131072KB    64bit IO Format:%I64d & %I64u
 tan xin ti;

Description

Xueba: Using the 4-Point Scale, my GPA is 4.0.

In fact, the AVERAGE SCORE of Xueba is calculated by the following formula:
AVERAGE SCORE = ∑(Wi * SCOREi) / ∑(Wi) 1<=i<=N

where SCOREi represents the scores of the ith course and Wi represents the credit of the corresponding course.

To simplify the problem, we assume that the credit of each course is 1. In this way, the AVERAGE SCORE is ∑(SCOREi) / N. In addition, SCOREi are all integers between 60 and 100, and we guarantee that ∑(SCOREi) can be divided by N.

In SYSU, the university usually uses the AVERAGE SCORE as the standard to represent the students’ level. However, when the students want to study further in foreign countries, other universities will use the 4-Point Scale to represent the students’ level. There are 2 ways of transforming each score to 4-Point Scale. Here is one of them.


The student’s average GPA in the 4-Point Scale is calculated as follows:
GPA = ∑(GPAi) / N

So given one student’s AVERAGE SCORE and the number of the courses, there are many different possible values in the 4-Point Scale. Please calculate the minimum and maximum value of the GPA in the 4-Point Scale.
 

Input

The input begins with a line containing an integer T (1 < T < 500), which denotes the number of test cases. The next T lines each contain two integers AVGSCORE, N (60 <= AVGSCORE <= 100, 1 <= N <= 10).
 

Output

For each test case, you should display the minimum and maximum value of the GPA in the 4-Point Scale in one line, accurate up to 4 decimal places. There is a space between two values.
 

Sample Input

475 175 275 375 10
 

Sample Output

3.0000 3.00002.7500 3.00002.6667 3.16672.4000 3.2000

Hint

In the third case, there are many possible ways to calculate the minimum value of the GPA in the 4-Point Scale. For example, Scores 78 74 73 GPA = (3.0 + 2.5 + 2.5) / 3 = 2.6667 Scores 79 78 68 GPA = (3.0 + 3.0 + 2.0) / 3 = 2.6667 Scores 84 74 67 GPA = (3.5 + 2.5 + 2.0) / 3 = 2.6667 Scores 100 64 61 GPA = (4.0 + 2.0 + 2.0) / 3 = 2.6667 
#include<cmath>#include<queue>#include<cstdio>#include<cstring>#include<stack>using namespace std;int Rank(int x){    if(x>=60&&x<=69)        return 0;    if(x>=70&&x<=74)        return 1;    if(x>=75&&x<=79)        return 2;    if(x>=80&&x<=84)        return 3;    if(x>=85&&x<=100)        return 4;    return -1;}double rate[]= {2.0,2.5,3.0,3.5,4.0};int mf[]= {25,20,15,10};double g[]= {2.0,1.5,1.0,0.5};int main(){    int m,n,t;    int x;    double sum;    int yu,ans;    while(~scanf("%d",&t))    {        while(t--)        {            scanf("%d%d",&n,&m);            if(m==1)            {                x=Rank(n);                printf("%.4lf %.4lf\n",rate[x],rate[x]);                continue;            }            yu=n*m-m*69;            if(yu<=0)                printf("2.0000");            else            {                sum=2.0*m;                sum+=(yu/31)*2.0;                yu=yu%31;                x=Rank(yu+69);                sum+=rate[x]-2.0;                printf("%.4lf",sum*1.0/m);            }            yu=m*n-m*60;            sum=m*2.0;            for(int i=0; i<4; i++)            {                if(yu>=mf[i])                {                    ans=yu/mf[i];                    sum+=ans*g[i];                    yu=yu%mf[i];                }            }            double k=sum*1.0/m;            if(k>4.0)                k=4.0;            printf(" %.4lf\n",k);        }    }    return 0;}

 

FAQ | About Virtual Judge | Forum | Discuss | Open Source Project
All Copyright Reserved ©2010-2014 HUST ACM/ICPC TEAM
Anything about the OJ, please ask in the forum, or contact author:Isun
Server Time: 2015-08-08 18:13:38
0 0
原创粉丝点击