【瞎搞】HDU 4968 Improving the GPA

来源:互联网 发布:超级淘客软件 编辑:程序博客网 时间:2024/05/16 16:14

枚举一种GPA有多少个

总分1加上该GPA的最小分数

总分2加上该GPA的最大分数

若总分1<=输入分数×n<=总分2

则可以在枚举的状态达到目标分数

#include <stdio.h>#include <string.h>#include <math.h>#include <string>#include <algorithm>using namespace std;#define IN     freopen ("in.txt" , "r" , stdin);#define OUT  freopen ("out.txt" , "w" , stdout);typedef long long  LL;const int M= 100100;double getmin,getmax;double ok[5]= {2,2.5,3,3.5,4};int len[5][2]= {{60,69},{70,74},{75,79},{80,84},{85,100}};int n;void dfs(int num,int tol1,int tol2,double fen,int cheng){    if(num==n&&cheng==-1&&tol1>=0&&tol2<=0)    {        getmax=max(getmax,fen);        getmin=min(getmin,fen);        return ;    }    else if(cheng>=0)    {        for(int i=0; i<=n-num; i++)        {            dfs(num+i,tol1-len[cheng][0]*i,tol2-len[cheng][1]*i,fen+ok[cheng]*i,cheng-1);        }    }}int main(){    int t;    scanf("%d",&t);    while(t--)    {        int ave;        getmax=-1,getmin=10000;        scanf("%d%d",&ave,&n);        dfs(0,ave*n,ave*n,0,4);        printf("%.4lf %.4lf\n",getmin/n,getmax/n);    }    return 0;}


0 0