HDU 4968 Improving the GPA Simulation

Source: Internet
Author: User

The minimum value is 69, and the maximum value is 85.

..


#include <cstdio>#include <iostream>#include <algorithm>#include <string.h>#include <math.h>#include <vector>#include <map>#include <queue>using namespace std;#define N 5000int av, n;int s[N];double go(int x){    if(x< 60)return 0;    if(x<=69)return 2;    if(x<=74)return 2.5;    if(x<=79)return 3;    if(x<=84)return 3.5;    return 4;}double work1(){    int all = av * n;    all -= 60*n;    for(int i = 0; i < n; i++) s[i] = 60;    for(int i = 0; i < n && all; i++) {        int tmp = min(all, 85-60);        all -= tmp;        s[i] += tmp;    }    double ans = 0;    for(int i = 0; i < n; i++)        ans += go(s[i]);    return ans / (double)n;}double work2(){    int all = av * n;    all -= 69*n;    if(all <= 0)return 2.0;    for(int i = 0; i < n; i++)        s[i] = 69;    for(int i = 0; i < n && all; i++) {        int tmp = min(all, 100-69);        all -= tmp;        s[i] += tmp;    }    double ans = 0;    for(int i = 0; i < n; i++)        ans += go(s[i]);    return ans / (double)n;}int main(){    int i, j, T;scanf("%d",&T);    while(T--){        scanf("%d %d",&av,&n);        double mx = work1(), mi = work2();        printf("%.4lf %.4lf\n",mi, mx);    }    return 0;}/*9975 175 275 375 1060 10100 1085 10100 160 180 1074 1070 10*/


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.