2014 simple DP questions that can be obtained from nine I questions of multiple HDU students without DP

Source: Internet
Author: User

After listening to the great idea of zwk, I immediately went to 1A.

The idea is as follows:

When calculating the minimum GPA, first, each subject is allocated to 69 points (if not enough, GPA 2 is output directly), and then the for loop is used to reduce the remain point. The maximum value of each subject is increased to 100.

When calculating the maximum GPa, each subject is allocated to 60 points, and then the for loop is used to reduce the remain point. The upper limit of each subject is increased to 85. If there is a remain point, add the for loop to the 100 upper limit.

 

No DP Ah Qaq

After a while, it looks good. DP =

So I marked this question as "water question set" silently.

    //#pragma comment(linker, "/STACK:16777216") //for c++ Compiler    #include <stdio.h>    #include <iostream>    #include <cstring>    #include <cmath>    #include <stack>    #include <queue>    #include <vector>    #include <algorithm>    #define ll long long    #define Max(a,b) (((a) > (b)) ? (a) : (b))    #define Min(a,b) (((a) < (b)) ? (a) : (b))    #define Abs(x) (((x) > 0) ? (x) : (-(x)))    #define NN 200011    using namespace std;    const ll INF = 0x3f3f3f3f;    const ll MAXN = 300001;    int main(){        int i, j, n, m, k;        int numCase;        int score, sum;        int a[11];        scanf("%d",&numCase);        while(numCase--){            double Gmax = 0.0;            double Gmin = 0.0;            scanf("%d%d",&score,&n);            sum = score * n;            if(score < 60)  Gmax = 2;            else{                for(i = 1; i <= n; ++i){                    a[i] = 60;                }                int remain = sum - n * 60;                while(remain != 0){                    for(i = 1; i <= n; ++i){                        if(a[i] <= 85){                            int delta = 85 - a[i];                            if(remain > delta){                                a[i] += delta;                                remain -= delta;                            } else{                                a[i] += remain;                                remain = 0;                                break;                            }                        }                    }                    for(i = 1; i <= n; ++i){                        if(a[i] <= 100){                            int delta = 100 - a[i];                            if(remain > delta){                                a[i] += delta;                                remain -= delta;                            } else{                                a[i] += remain;                                remain = 0;                                break;                            }                        }                    }                }                for(i = 1; i <= n; ++i){                    if(a[i] >= 85)  Gmax += 4.0;                    else if(a[i] >= 80) Gmax += 3.5;                    else if(a[i] >= 75) Gmax += 3.0;                    else if(a[i] >= 70) Gmax += 2.5;                    else if(a[i] >= 60) Gmax += 2.0;                }                Gmax /= n;            }            if(score < 69)  Gmin = 2;            else{                for(i = 1; i <= n; ++i){                    a[i] = 69;                }                int remain = sum - n * 69;                while(remain != 0){                    for(i = 1; i <= n; ++i){                        if(a[i] <= 100){                            int delta = 100 - a[i];                            if(remain > delta){                                a[i] += delta;                                remain -= delta;                            } else{                                a[i] += remain;                                remain = 0;                                break;                            }                        }                    }                }                for(i = 1; i <= n; ++i){                    if(a[i] >= 85)  Gmin += 4.0;                    else if(a[i] >= 80) Gmin += 3.5;                    else if(a[i] >= 75) Gmin += 3.0;                    else if(a[i] >= 70) Gmin += 2.5;                    else if(a[i] >= 60) Gmin += 2.0;                }                Gmin /= n;            }            printf("%.4f %.4f\n",Gmin,Gmax);        }        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.