Address: HDU 4968
This is done by enumerating the credits of all subjects and then determining if the average score is met in this case. You can directly list brute-force data.
The Code is as follows:
#include <cstring>#include <cstdio>#include <math.h>#include <algorithm>using namespace std;int main(){ int t, n, a, i, tot, j, k, h, i1, j1, k1, h1, i2, j2, k2, h2; double max1, tmp, min1; scanf("%d",&t); while(t--) { scanf("%d%d",&a,&n); max1=-1; min1=1e9; a*=n; for(i=0; i<=n; i++) { i1=i*100; i2=i*85; for(j=0; j<=n-i; j++) { j1=j*84; j2=j*80; for(k=0; k<=n-i-j; k++) { k1=k*79; k2=k*75; for(h=0; h<=n-i-j-k; h++) { h1 = h * 74 ; h2 = h * 70 ; int z=n-i-j-k-h; ////printf("zz --- %d %d %d %d %d\n" , i, j, k, h, z); int maxans=i1+j1+k1+h1+z*69; int minans=i2+j2+k2+h2+z*60; if(a>=minans&&a<=maxans) { //printf("kkkk --- %d %d %d %d %d\n" , i, j, k, h, z); tmp=i*4+j*3.5+k*3.0+h*2.5+z*2; if(max1<tmp) { max1=tmp; //printf("max --- %d %d %d %d %d\n" , i, j, k, h, z); } if(min1>tmp) { min1=tmp; //printf("min --- %d %d %d %d %d\n" , i, j, k, h, z); } } } } } } printf("%.4lf %.4lf\n",min1/n,max1/n); } return 0;}