首页 > 代码库 > HDU 4968(杭电多校#9 1009题)Improving the GPA (瞎搞)

HDU 4968(杭电多校#9 1009题)Improving the GPA (瞎搞)

题目地址:HDU 4968

这题的做法是全部学科的学分情况枚举,然后推断在这样的情况下是否会符合平均分。

直接暴力枚举就可以。

代码例如以下:

#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;
}


HDU 4968(杭电多校#9 1009题)Improving the GPA (瞎搞)