1388 - Graveyard
Programming contests became so popular in the year 2397 that the governor of New Earck -- the largest human-inhabited planet of the galaxy -- opened a special Alley of Contestant Memories (ACM) at the local graveyard.
The ACM encircles a green park, and holds the holographic statues of famous contestants placed equidistantly along the park perimeter. The alley has to be renewed from time to time when a new group of memorials arrives.
When new memorials are added, the exact place for each can be selected arbitrarily along the ACM, but the equidistant disposition must be maintained by moving some of the old statues along the alley.
Surprisingly, humans are still quite superstitious in 24th century: the graveyard keepers believe the holograms are holding dead people souls, and thus always try to renew the ACM with minimal possible movements
of existing statues (besides, the holographic equipment is very heavy). Statues are moved along the park perimeter. Your work is to find a renewal plan which minimizes the sum of travel distances of all statues. Installation of a new hologram adds no distance
penalty, so choose the places for newcomers wisely!
The input file contains several test cases, each of them consists of a a line that contains two integer numbers:n--
the number of holographic statues initially located at the ACM, and
m-- the number of statues to be added
(2n1000,
1m1000).
The length of the alley along the park perimeter is exactly 10 000 feet.
For each test case, write to the output a line with a single real number -- the minimal sum of travel distances of all statues (in feet). The answer must be precise to at least 4 digits after decimal point.
Pictures show the first three examples. Marked circles denote original statues, empty circles denote new equidistant places, arrows denote movement plans for existing statues.
2 1
2 3
3 1
10 10
1666.6667
1000.0
1666.6667
0.0
【解析】
【代码】
/*********************************
* 日期:2013-11-25
* 作者:SJF0115
* 题号: 题目1388 - Graveyard
* 来源:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=446&page=show_problem&problem=4134
* 结果:AC
* 来源:UVA
* 总结:
**********************************/
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
int i,n,m;
while(scanf("%d %d",&n,&m) != EOF){
double ans = 0.0;
for(i = 1;i < n;i++){
//计算每个需要移动的雕塑坐标
double pos = (double)i / n * (n+m);
//累加移动距离
ans += fabs(pos - floor(pos+0.5))/(n+m);
}
printf("%.4lf\n",ans * 10000);
}//while
return 0;
}
分享到:
相关推荐
Blockchain-Graveyard, 所有公开的区块事件 区块墓地公开的区块事件,包括入侵或者受害者声明的细节。https://magoo.github.io/Blockchain-Graveyard/这里站点由两个主要部分组成: Graveyard 是一个大事件的枚举,...
技术采访墓地 这是所有面试问题的工作台存储,其中包含我在面试中遇到的或在准备过程中偶然发现的解决方案。
JS墓地(复活) 未能成功的纯Javascript和jQuery原型。 关于 他们有很大的希望,但是浏览器实现方式的差异杀死了他们。 我所面临的大多数问题,当您在各种Web浏览器上运行这些脚本时会立即注意到,这与动画性能...
高质量的墓地和公墓资产。 非常适合2D游戏,例如平台,射击游戏或无尽的跑步者。拥有 100多种平台,插件,背景精灵,非常适合创建很多品种! 包装包括: -20个坟墓/陵墓 -6个平台元素 -5个雕像 ...
自述 此自述文件通常会记录启动和运行应用程序所需的任何步骤。 您可能想要涵盖的内容: Ruby版 系统依赖 配置 数据库创建 数据库初始化 如何运行测试套件 服务(作业队列、缓存服务器、搜索引擎等) ...
Graveyard一道ACM的题,利用了很巧妙的思维方法
(不同之处在于,有关变量类型的信息保存在文件中,这意味着每个值都包装在一个对象中)。 导出为JSON时,您还可以选择.html来创建一个网站,在该网站中您可以相对轻松地在浏览器控制台中编辑保存,然后再次将其...
Graveyard是尝试重新实现 (在本文中称为DDCZ)的源代码。 开发人员的文档。 生产将在 会费 如果您同意将您的工作与Graveyard(MIT)共享,则可以提供贡献。 如果你不知道从哪里开始,看看问题或要求Almad上或波...
Graveyard 是一个协作文本编辑器。 它允许用户同步或不同步编辑相同的文本文档。
Graveyard是一个多用途的 Java 库,由 iBit-Tech 的 xbony2 创建。 它是在 MIT 许可下获得许可的,因此可以随意用于游戏、程序等! 如果要将它用于任何特别的事情,请提醒 xbony2,他很高兴听到您的创作! :D 贡献 ...
Graveyard Invasion 是一款基于波浪的像素风格游戏。 游戏的目标是,尽可能长时间地对抗邪恶的蜘蛛和蝙蝠。 很多通电都会帮助你。
remove-dagmc-tags -i dagmc.h5m -o dagmc_no_graveyard.h5m -t graveyard -i或--input参数指定输入--input文件 -o或--output参数指定输出h5m或vtk文件名 -t或--tags参数指定要删除的标签。 -v或--verbose参数启用...
WorkAdventure Map入门套件这是一个入门工具包,可帮助您为构建自己的地图。 要了解如何使用该入门工具包,请按照的教程进行操作。
墓地这个简单的 express 中间件将缓存那些 410 (gone) 请求。 用法: 如果 app 是您的快速应用程序,请将这个中间件添加到中间件堆栈中。... use ( require ( 'graveyard' ) ( [ '/url/to/ignore' ] ) ) ;
新闻业的死项目++ 安装 安装node和npm然后运行: make install 您现在可以开始用gulp服务静态文件了! make run 在Git页面上部署 运行以下命令 make deploy
Many test automation endeavors end up in the “graveyard” of software projects. There are many things that affect the value of test automation, and also its costs. This book aims to cover all of ...
巴菲 吸血鬼猎人巴菲引述的财富mod ... You just don't sneak up on people in a graveyard. You make noise when you walk, you stomp, or... yodel. 再次。 fortune buffy Buffy: What do you want? S
Many test automation endeavors end up in the “graveyard” of software projects. There are many things that affect the value of test automation, and also its costs. This book aims to cover all of ...
被谷歌杀死 Google杀害的最受欢迎的产品和服务的致敬和日志。 有助于 要添加产品,请收集以下信息: 产品名称( name ) ...切换到该分支(如果您刚刚创建了该分支,它将自动发生)并打开graveyard.json文件 使
删除的文件将在其绝对路径下发送到坟墓场(默认情况下/tmp/graveyard-$USER ,有关更改此),这使您有机会恢复它们。 没有数据被覆盖。 如果删除共享同一路径的文件,它们将被重命名为编号备份。 rip是为懒惰的人...