poj 3154 Graveyard 贪心
//poj 3154
//sep9
#include <iostream>
#include <cmath>
using namespace std;
double a[2048];
double b[2048]; int main()
{
int n,m;
while(scanf("%d%d",&n,&m)==2){
for(int i=0;i<n;++i)
a[i]=i*(10000.0/n);
for(int i=0;i<(n+m);++i)
b[i]=i*(10000.0/(n+m));
double ans=0;
for(int i=0;i<n;++i){
double minx=9999999.9;
for(int j=0;j<m+n;++j)
minx=min(minx,fabs(a[i]-b[j]));
ans+=minx;
}
printf("%.4lf\n",ans);
}
return 0;
}
poj 3154 Graveyard 贪心的更多相关文章
- POJ 3154 Graveyard【多解,数论,贪心】
Graveyard Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 1707 Accepted: 860 Specia ...
- LA 3708 && POJ 3154 Graveyard (思维)
题意:在周长为10000的圆上等距分布着n个雕塑,现在又加入m个,现在让m+n个等距分布,那就得移动一些原有的雕塑,问你移动的最少总距离是多少. 析:首先我们可以知道,至少有一个雕塑是可以不用移动的, ...
- POJ 1456(贪心)
#include <string.h> #include <iostream> #include <queue> #include <stdio.h> ...
- poj -3614 Sunscreen(贪心 + 优先队列)
http://poj.org/problem?id=3614 有c头奶牛在沙滩上晒太阳,每头奶牛能忍受的阳光强度有一个最大值(max_spf) 和最小值(min_spf),奶牛有L种防晒霜,每种可以固 ...
- POJ 3614 Sunscreen 贪心
题目链接: http://poj.org/problem?id=3614 Sunscreen Time Limit: 1000MSMemory Limit: 65536K 问题描述 to avoid ...
- POJ 1456 - Supermarket - [贪心+小顶堆]
题目链接:http://poj.org/problem?id=1456 Time Limit: 2000MS Memory Limit: 65536K Description A supermarke ...
- poj 3404&&poj1700(贪心)
Bridge over a rough river Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4143 Accept ...
- poj 2287(贪心)
Tian Ji -- The Horse Racing Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 12490 Acc ...
- poj 2431 Expedition 贪心 优先队列 题解《挑战程序设计竞赛》
地址 http://poj.org/problem?id=2431 题解 朴素想法就是dfs 经过该点的时候决定是否加油 中间加了一点剪枝 如果加油次数已经比已知最少的加油次数要大或者等于了 那么就剪 ...
随机推荐
- 命令行,备份、导入数据库Oracle
备份库:exp username/password@Database file="h:\datas.dmp" owner=username 导入语句 :imp username2/ ...
- jquery中的ajax方法详解
定义和用法ajax() 方法通过 HTTP 请求加载远程数据.该方法是 jQuery 底层 AJAX 实现.简单易用的高层实现见 $.get, $.post 等.$.ajax() 返回其创建的 XML ...
- IE8 不支持Date.now()
Date.now() 返回1970 年 1 月 1日午夜与当前日期和时间之间的毫秒数. 以下是微软的描述: 在早于 Internet Explorer 9 的安装版本中不受支持. 但是,在以下文档模式 ...
- bzoj1136: [POI2009]Arc
Description 给定一个序列{ai | 1 <= ai <= 1000000000 且 1 <= i <= n 且 n <= 15000000}和一个整数 k ( ...
- Laravel框架——自己写的类找不到
composer.json my model files are stored in directory of app\models, therefor "autoload": { ...
- study note--(Education)
some good temoplates: A child's education has never been about learning information and basic skills ...
- github上值得研究的项目和人
https://github.com/Dax89?tab=repositories https://github.com/stars/gabrielcorado https://github.com/ ...
- UpdateLayeredWindow是炫效果的关键
自绘——是的,输入框每个字都自己绘制,计算行宽,行高,模拟光标闪烁,处理输入法的各种事件,以及选中,拖动等功能. 支持支持一下,实际上无句柄的,就是多行富文本编辑比较麻烦,其他的,都不复杂.很容易实现 ...
- linux eclipse c++配置
安装cdt: https://www.eclipse.org/cdt/downloads.php 新建一个c++工程,运行发生错误: Eclipse CDT launch failed.Binary ...
- kernel解读之 pick_next_rt_entity
1328 static struct sched_rt_entity *pick_next_rt_entity(struct rq *rq, 1329 struct rt_rq *rt_rq) 133 ...