HDU 4968 (hangdian multi-school #9 1009) Improving the GPA)

Source: Internet
Author: User

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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.