【瞎搞】HDU 4968 Improving the GPA

枚举一种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;
}

【瞎搞】HDU 4968 Improving the GPA,布布扣,bubuko.com

时间: 2024-08-08 09:38:06

【瞎搞】HDU 4968 Improving the GPA的相关文章

hdu 4968 Improving the GPA dp

[题意]:每个成绩范围对应一个绩点,给出平均分avg,课程数n,求能得到的平均绩点的最大值和最小值. [解法]:   d[i][j]表示总分为i 课程数为j时 可以得到的最大的总绩点. 状态转移为: d[i][j]=max(d[i][j],d[i-k][j-1]+d[k][1]);   (60<=k<=100&&i-k>=60*(j-1)) 1 #include<iostream> 2 #include<cstdio> 3 #include<

HDU 4968 Improving the GPA

Problem Description Xueba: Using the 4-Point Scale, my GPA is 4.0. In fact, the AVERAGE SCORE of Xueba is calculated by the following formula: AVERAGE SCORE = ∑(Wi * SCOREi) / ∑(Wi) 1<=i<=N where SCOREi represents the scores of the ith course and Wi

HDU 4968 Improving the GPA(dp)

HDU 4968 Improving the GPA 题目链接 dp,最大最小分别dp一次,dp[i][j]表示第i个人,还有j分的情况,分数可以减掉60最为状态 代码: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int t, avg, n; double dp1[15][405], dp2[15][405]; double get(int x) { if

hdu 4968 Improving the GPA (水 暴力枚举)

题目链接 题意:给平均成绩和科目数,求可能的最大学分和最小学分. 分析: 枚举一下,可以达到复杂度可以达到10^4,我下面的代码是10^5,可以把最后一个循环撤掉. 刚开始以为枚举档次的话是5^10,但是这个又不要求顺序,所以只是枚举个数就行了.. 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <cmath&g

HDU 4968 Improving the GPA 模拟

最小时就都当69,最大时都当85 .. #include <cstdio> #include <iostream> #include <algorithm> #include <string.h> #include <math.h> #include <vector> #include <map> #include <queue> using namespace std; #define N 5000 int

hdu 4968 Improving the GPA(暴力枚举)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4970 Problem Description Xueba: Using the 4-Point Scale, my GPA is 4.0. In fact, the AVERAGE SCORE of Xueba is calculated by the following formula: AVERAGE SCORE = ∑(Wi * SCOREi) / ∑(Wi) 1<=i<=N where S

HDU 4968 Improving the GPA 多校第九场1009

Problem Description Xueba: Using the 4-Point Scale, my GPA is 4.0. In fact, the AVERAGE SCORE of Xueba is calculated by the following formula: AVERAGE SCORE = ∑(Wi * SCOREi) / ∑(Wi) 1<=i<=N where SCOREi represents the scores of the ith course and Wi

HDOJ 4968 Improving the GPA

枚举... Improving the GPA Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 158    Accepted Submission(s): 126 Problem Description Xueba: Using the 4-Point Scale, my GPA is 4.0. In fact, the AVER

2014多校训练九(HDU 4960 HDU 4961 HDU 4965 HDU 4968 HDU 4969 HDU 4970)

HDU 4960 Another OCD Patient 题意:给你一串数字  相邻x个数字合并成一个数字(相加)有一定代价  问  最少花费多少使得串变成回文串 思路: 读完题感觉像dp  数据范围也像  就开始想怎么表示状态  最简单的应该想到dp[i][j]表示i到j区间变成回文串的最小花费  状态想好了想做法  考虑将串分成AAAABBBBBBBCCC三段  即所有A合成一个数字  C也是  而且A和C相等  那么B串就变成了子问题  但是A和C是不是都要枚举呢?  这个串所有元素都是正