最小时就都当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 5000 int 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; } /* 99 75 1 75 2 75 3 75 10 60 10 100 10 85 10 100 1 60 1 80 10 74 10 70 10 */
HDU 4968 Improving the GPA 模拟,布布扣,bubuko.com
原文:http://blog.csdn.net/qq574857122/article/details/38686755