HDU 4968 Improving the GPA 模拟

来源:互联网 发布:三级网络技术题库软件 编辑:程序博客网 时间:2024/06/04 18:21

最小时就都当69,最大时都当85

。。


#include <cstdio>#include <iostream>#include <algorithm>#include <string.h>#include <math.h>#include <vector>#include <map>#include <queue>using namespace std;#define N 5000int av, n;int s[N];double go(int x){    if(x< 60)return 0;    if(x<=69)return 2;    if(x<=74)return 2.5;    if(x<=79)return 3;    if(x<=84)return 3.5;    return 4;}double work1(){    int all = av * n;    all -= 60*n;    for(int i = 0; i < n; i++) s[i] = 60;    for(int i = 0; i < n && all; i++) {        int tmp = min(all, 85-60);        all -= tmp;        s[i] += tmp;    }    double ans = 0;    for(int i = 0; i < n; i++)        ans += go(s[i]);    return ans / (double)n;}double work2(){    int all = av * n;    all -= 69*n;    if(all <= 0)return 2.0;    for(int i = 0; i < n; i++)        s[i] = 69;    for(int i = 0; i < n && all; i++) {        int tmp = min(all, 100-69);        all -= tmp;        s[i] += tmp;    }    double ans = 0;    for(int i = 0; i < n; i++)        ans += go(s[i]);    return ans / (double)n;}int main(){    int i, j, T;scanf("%d",&T);    while(T--){        scanf("%d %d",&av,&n);        double mx = work1(), mi = work2();        printf("%.4lf %.4lf\n",mi, mx);    }    return 0;}/*9975 175 275 375 1060 10100 1085 10100 160 180 1074 1070 10*/


0 0
原创粉丝点击