hdu4968
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=4968
说是考dp,但是我没出来dp在哪,可能贪心思想更多一些吧。
AC代码:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define ll long long
const int maxn=1e5+;
const int INF=0x3f3f3f3f; int score,n; double mx(int x)
{
double ans;
if(score>=) return 4.0*n;
ans=2.0*n;
x-=*n;
for(int i=;i<=n;i++)
{
if(x>) {x-=;ans+=0.5;} else break; ///
if(x>) {x-=;ans+=0.5;} else break; ///
if(x>) {x-=;ans+=0.5;} else break; ///
if(x>) {x-=;ans+=0.5;} else break; ///
}
return ans;
} double mn(int x)
{
double ans;
if(score<) return 2.0*n;
ans=2.0*n;
x-=*n;
for(int i=;i<=n;i++)
{
if(x>) {x-=;ans+=0.5;} else break; ///
if(x>) {x-=;ans+=0.5;} else break; ///
if(x>) {x-=;ans+=0.5;} else break; ///
if(x>) {x-=;ans+=0.5;} else break; ///
}
return ans;
} int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&score,&n);
int sum=score*n;
double minn=mn(sum);
double maxx=mx(sum);
printf("%.4f %.4f\n",minn/n,maxx/n);
}
return ;
}
hdu4968的更多相关文章
- Improving the GPA(hdu4968)dfs
Improving the GPA Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
随机推荐
- linux查看系统版本和系统位数
1. uname -a you will view kernel name.network node hostname.kernel release.kernel version.machine h ...
- php 与 js 正则匹配
php : <?php $str='<p>xxx</p>abc';$matches = array();if(preg_match('/<p>.*<\/ ...
- September 11th 2016 Week 38th Sunday
Nothing happens unless first a dream. 一切始于梦想. When everything seems to be going against you, remembe ...
- ios layer 动画-(transform.rotation篇)
x轴旋转: CABasicAnimation *theAnimation; theAnimation=[CABasicAnimation animationWithKeyPath:@"tra ...
- DB2应用中嵌入式SQL取值入本地变量
Declare section for host variables in C and C++ embedded SQL applications You must use an SQL declar ...
- Struts2拦截器之FileUploadInterceptor
一.它能做什么? 借助于这个拦截器我们可以实现文件的上传和下载功能. 理论部分: struts2的文件上传下载功能也要依赖于Apache commons-fileupload和Apache commo ...
- 3.2 STL中的函数对象类模板
*: STL中有一些函数对象类模板,如下所示: 1)例如要求两个double类型的x 和y 的积,可以: multiplies<double>()(x,y); 该表达式的值就是x*y的值. ...
- Android -- java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
使用Bundle 的getParcelableArray 出现了以下错误: Class not found when unmarshallingjava.lang.ClassNotFoundExcep ...
- Filp Game
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 25573 Accepted: 11052 题目链接: ...
- Ajax 数据库操作
为了清楚的说明使用 Ajax 从数据库中存取信息有多么容易,我们要构建一个 MySQL 查询,然后把结果显示在ajax.html 上.但是在我们开始之前,让我们先做一些基础工作.使用下面的命令创建一个 ...