hdu 4968 Improving the GPA
来源:互联网 发布:淘宝开过店可以再开吗 编辑:程序博客网 时间:2024/05/18 00:03
题目链接:点击打开链接
贪心规则:求最大值时,在保证剩下的分数除以剩下学科数的平均分数大于60小于100的情况下,每次选取能选取的最大区间的最小值,如先选85,再选80.。。
求最小值同理。
要考虑处理到只有一个学科和学科平均分小于65||大于95的情况。
代码:
#include <iostream>#include <cstdio>using namespace std;double getscore(double n){ if(n>=60&&n<=69) return 2; else if(n>=70&&n<=74) return 2.5; else if(n>=75&&n<=79) return 3; else if(n>=80&&n<=84) return 3.5; else return 4;}double getmax(int s,int n){ double tot=s*n; int num=n; double cur=0; for(int t=85;t>=60;t-=5){ if(n==1)break; for(int i=1;i<num;i++){ if(n==1) break; if(((tot-t)/(n-1))>=60&&((tot-t)/(n-1))<=100){ tot-=t; cur+=getscore(t); n--; } else break; } } if(tot>=100) cur+=4*(tot/100); else cur+=getscore(tot); if(s>=85) return 4; return cur/num;}double getmin(int s,int n){ double tot=s*n; int num=n; double cur=0; for(int t=69;t<=99;t+=5){ if(n==1)break; for(int i=1;i<num;i++){ if(n==1) break; if(((tot-t)/(n-1))>=60&&((tot-t)/(n-1))<=100){ tot-=t; cur+=getscore(t); n--; } else break; } } if(tot>=100) cur+=4*(tot/100); else cur+=getscore(tot); if(s<=69) return 2; return cur/num;}int main(){ int T; cin>>T; while(T--){ int s,n; cin>>s>>n; printf("%.4lf %.4lf\n",getmin(s,n),getmax(s,n)); } return 0;}
0 0
- HDU 4968 Improving the GPA
- hdu 4968 Improving the GPA
- hdu 4968 Improving the GPA
- HDU 4968 Improving the GPA 模拟
- 【瞎搞】HDU 4968 Improving the GPA
- HDU 4968 Improving the GPA【数学】【暴力】
- HDU-4968 Improving the GPA 暴力枚举
- HDU 4968 Improving the GPA(dp)
- hdu 4968 Improving the GPA(dp)
- HDU 4968 Improving the GPA 贪心
- hdu 4968 Improving the GPA (dp)
- HDU-4968 Improving the GPA (DP)
- HDOJ 4968 Improving the GPA
- 【HDOJ 4968】 Improving the GPA
- HDU 4968 Improving the GPA 多校第九场1009
- hdu 4968 Improving the GPA(暴力枚举)
- HDU 4968 Improving the GPA——暴力
- [HDOJ 4968] Improving the GPA [贪心]
- Servlet处理Json请求数据包
- GO語言視頻教程下載
- java web项目防止多用户重复登录解决方案
- jtable全选与取消选择
- 机房收费系统问题集(5)——报表(日结,周结账单)
- hdu 4968 Improving the GPA
- Jump Game II Java
- 2014-5-28 技能
- 在VC或是VS中添加快捷键
- C/C++——strcmp函数实现
- Oracle中merge into的使用
- android开源库
- android linux 10.4 编译环境
- [学习笔记]SVG初级篇