hdu 4968 Improving the GPA (水 暴力枚举)
题意:给平均成绩和科目数,求可能的最大学分和最小学分。
分析:

枚举一下,可以达到复杂度可以达到10^4,我下面的代码是10^5,可以把最后一个循环撤掉。
刚开始以为枚举档次的话是5^10,但是这个又不要求顺序,所以只是枚举个数就行了。。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define LL __int64
const int maxn = +;
const int INF = <<;
using namespace std; int main()
{
int t, i, j, k, l, m, sc, n, sum1, sum2, y;
double gp, ans1, ans2;
scanf("%d", &t);
while(t--)
{
ans1 = INF;
ans2 = -;
scanf("%d%d", &sc, &n);
y = sc*n; for(i = ; i <= n; i++)
for(j = ; j <= n-i; j++)
for(k = ; k <= n-i-j; k++)
for(l = ; l <= n-i-j-k; l++)
for(m = ; m <= n-i-j-k-l; m++)
{
if(i+j+k+l+m==n)
{
//printf("%d %d %d %d %d\n", i, j, k, l, m);
sum1 = (i*+j*+k*+l*+m*);
sum2 = (i*+j*+k*+l*+m*);
gp = i*+j*2.5+k*+l*3.5+m*; if(y>=sum1&&y<=sum2)
{
if(gp<ans1) ans1 = gp;
if(gp>ans2) ans2 = gp;
}
}
}
//cout<<ans1<<endl;
ans1 = ans1*1.0/n;
ans2 = ans2*1.0/n;
printf("%.4lf %.4lf\n", ans1, ans2);
}
return ;
}
hdu 4968 Improving the GPA (水 暴力枚举)的更多相关文章
- HDU 4968 Improving the GPA(dp)
HDU 4968 Improving the GPA 题目链接 dp.最大最小分别dp一次,dp[i][j]表示第i个人,还有j分的情况,分数能够减掉60最为状态 代码: #include <c ...
- HDU 4968 Improving the GPA
Improving the GPA Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Othe ...
- HDU - 1248 寒冰王座 数学or暴力枚举
思路: 1.暴力枚举每种面值的张数,将可以花光的钱记录下来.每次判断n是否能够用光,能则输出0,不能则向更少金额寻找是否有能够花光的.时间复杂度O(n) 2.350 = 200 + 150,买350的 ...
- hdu 4082 Hou Yi's secret(暴力枚举)
Hou Yi's secret Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu 4968 最大最小gpa
http://acm.hdu.edu.cn/showproblem.php?pid=4968 给定平均分和科目数量,要求保证及格的前提下,求平均绩点的最大值和最小值. dp[i][j]表示i个科目,总 ...
- HDU 5944 Fxx and string(暴力/枚举)
传送门 Fxx and string Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Othe ...
- HDU 5660 jrMz and angles (暴力枚举)
jrMz and angles 题目链接: http://acm.hust.edu.cn/vjudge/contest/123316#problem/E Description jrMz has tw ...
- hdu 5595 GTW likes math(暴力枚举查询)
思路:直接暴力枚举区间[l,r]的整数值,然后max和min就可以了. AC代码: #pragma comment(linker, "/STACK:1024000000,1024000000 ...
- hdu 5033 Building (单调栈 或 暴力枚举 )
Description Once upon a time Matt went to a small town. The town was so small and narrow that he can ...
随机推荐
- 微软职位内部推荐-Enterprise Architect - BDE - BJ
微软近期Open的职位: Enterprise ArchitectCloud, HTML5, Big Data and Mobile are technology trends driving pro ...
- inputstream与其他格式的转换
1.InputStream 转换成InputSource . InputStream inputStream = request.getInputStream(); InputSource input ...
- DB天气app冲刺二阶段第十天
昨天困到不行了 所以就写了那么几句..所以今天好好写写了要.. 今天的收获了一个很重要的问题 就还是api接口的事情,以前的那个接口虽然能用但是总是不稳定,今天由决定百度的一下然后就发现了一个很好用的 ...
- Jenkins部署.NET网站项目
Jenkins Jenkins是一个开源软件项目,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能. Jenkins是基于Java开发的一种持续集成工具,用于监控持续重复的工作,功能包括: 持 ...
- hibernate中增加annotation @后不提示信息【转】
此文转自:http://blog.knowsky.com/252047.htm 所需要用到的3个jar包分别是: hibernate-annotations.jar ejb3-persistence. ...
- codeforces GYM 100114 J. Computer Network 无相图缩点+树的直径
题目链接: http://codeforces.com/gym/100114 Description The computer network of “Plunder & Flee Inc.” ...
- NYOJ-171 聪明的kk AC 分类: NYOJ 2014-01-02 09:01 165人阅读 评论(0) 收藏
#include<stdio.h> #define max(x,y) x>y?x:y int main(){ int num[22][22]={0}; int n,m; int x, ...
- Unity3D脚本中文系列教程(二)
原地址:http://dong2008hong.blog.163.com/blog/static/469688272014030347910/ Unity3D脚本中文系列教程(一) .根据名称或标签定 ...
- mysql导出多个表数据为excel方法,substring函数查询
//查询sys_username以S.00655开头的用户 ),sys_password FROM `tbl_sa_syslogin` where sys_username like 'S.%'; / ...
- rabbitMQ安装及部署
1.安装 rpm -ivh erlang-18.3-1.el6.x86_64.rpm, 下载地址:http://www.rabbitmq.com/releases/erlang/ rpm --impo ...