Graveyard
Time Limit: 2000MS   Memory Limit: 65536K
Total Submissions: 1715   Accepted: 865   Special Judge

Description

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!

Input

Input file contains two integer numbers: n — the number of holographic statues initially located at the ACM, and m — the number of statues to be added (2 ≤ n ≤ 1000, 1 ≤ m ≤ 1000). The length of the alley along the park perimeter is exactly 10 000 feet.

Output

Write a single real number to the output file — the minimal sum of travel distances of all statues (in feet). The answer must be precise to at least 4 digits after decimal point.

Sample Input

sample input #1
2 1sample input #2
2 3sample input #3
3 1sample input #4
10 10

Sample Output

sample output #1
1666.6667sample output #2
1000.0sample output #3
1666.6667sample output #4
0.0

Hint

Pictures show the first three examples. Marked circles denote original statues, empty circles denote new equidistant places, arrows denote movement plans for existing statues.

Source

Northeastern Europe 2006

Regionals 2006 >> Europe - Northeastern

问题链接:UVAlive3708 UVA1388 POJ3154 Graveyard

问题简述:(略)

问题分析:(略)

程序说明:占个位置,以后说明。

题记:(略)

参考链接:(略)

AC的C++语言程序如下:

/* UVAlive3708 UVA1388 POJ3154 Graveyard */#include <iostream>
#include <stdio.h>using namespace std;int gcd(int m, int n)
{return n ? gcd(n, m % n) : m;
}int main()
{int n, m;while (scanf("%d%d", &n, &m) != EOF){int t = gcd(n, m);n /= t, m /= t;int ans = 0;for(int i=0; i<n; i++)ans += min(i, n - i);printf("%.4f\n", (double)ans / (n* (n + m)) * 10000);}return 0;
}

UVAlive3708 UVA1388 POJ3154 Graveyard【水题】相关推荐

  1. 水题/poj 1852 Ants

    1 /* 2 PROBLEM:poj1852 3 AUTHER:Nicole 4 MEMO:水题 5 */ 6 #include<cstdio> 7 using namespace std ...

  2. HDU2673-shǎ崽(水题)

    如果不能够直接秒杀的题,就不算水题.又应证了那句话,有时候,如果在水题上卡住,那么此题对于你来说,也就不算是水题了额~~ 刚睡醒,迷迷糊糊. 题目的意思很简单,求一个最大的,再求一个最小的.几乎是什么 ...

  3. 图论刷水题记录(二)(最短路-----SPFA算法)

    继第一篇的后续,又来刷水题了,写的是SPFA算法,这个算法的复杂度比较玄学,感觉能不用就不用了,但是他的好处就是可以判断负圈. 3月26日: 1.POJ 1847 Tram 题意:在一个交通网络上有N ...

  4. 图论刷水题记录(一)(最短路-----dijkstra算法)

    最近实在不知道干些什么,感觉自己除了水题什么都不会做,算了去刷一刷图论的水题吧本来想合起来一起发,想了想太长的话以后看起来也不方便,题目所以今天晚上就先发了dij部分,由上到下由易变难. 1.POJ ...

  5. hdu 2041:超级楼梯(水题,递归)

    超级楼梯Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submissio ...

  6. HDU2568 前进【水题】

    前进 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submiss ...

  7. CF Round #426 (Div. 2) The Useless Toy 思维 水题

    题目链接: http://codeforces.com/contest/834/problem/A 题目描述: 输入起始状态和结束状态和数列长度, 判断旋转方向是顺时针逆时针还是不合理 解题思路: 长 ...

  8. NUC1312 Sum【水题+数学题】

    Sum 时间限制: 1000ms 内存限制: 65536KB 通过次数: 1总提交次数: 1 问题描述 认为自然数是从1-N.将每个数和+或-联系起来,然后计算这个表达式的值我们得到一个和S.这个问题 ...

  9. Codeforces 864 A Fair Game 水题

    题目链接: http://codeforces.com/problemset/problem/864/A 题目描述: 看不是是不是一串数中只有两种数且这两种数字的数量是相同的 解题思路: 水题, 水过 ...

最新文章

  1. DeepMind又出大招!新算法MuZero登顶Nature,AI离人类规划又近了一步
  2. python小项目推荐项目-Python 的练手项目有哪些值得推荐?
  3. Spring boot 和Vue开发中CORS跨域问题
  4. oracle产品追溯,如何追溯AR到Receipt再到GL
  5. Android App内部自动更新Library的使用(转载)
  6. centos下安装ruby,删除ruby
  7. 一个实例告诉你Python中关于 if __name__ == ‘__main__‘ 有何作用
  8. shell脚本编程测试类型下
  9. Java数字分类给定一系列正整数,请按要求对数字进行分类,并输出以下5个数字:A1 = 能被5整除的数字中所有偶数的和;A2 = 将被5除后余1的数字按给出顺序进行交错求和,即计算n1-n2+n3
  10. 【2016年第1期】农业大数据资产管理面临的挑战与思考
  11. 家谱树(信息学奥赛一本通-T1351)
  12. 计算任意两个圆的交点
  13. 用 SOLID 原则保驾 React 组件开发
  14. 大热的麦克风阵列语音识别系统的设计和轻松实现,提供软硬件解决方案
  15. 数字信号C语言——平均分布随机数
  16. Python实现空间直角坐标转高斯克吕格平面坐标
  17. Python数据可视化-基于Python-matplotlib
  18. 代做assignment分享高分Essay写作攻略
  19. 2016新年读书计划
  20. eos 测试网搭建,单节点,并使用命令行完成系统合约部署、账户创建、资产转账

热门文章

  1. 插入始终是1_插入式电磁流量计的安装说明
  2. 开源GIS(三)——openlayers地图基本框架与天地图加载
  3. TS笔记--------Jonathan
  4. MyBatis----resultMap的使用
  5. 局域网怎么查看单位摄像头_一行代码,实现多平台文件查看传输!
  6. 机器学习代码实战——决策树(预测泰坦尼号船员生存情况)
  7. linux打印全部make编译信息
  8. 最短路径之弗洛伊德算法
  9. 将所有的表中,数值类型由char,varchar改为nchar,nvarchar 的存储过程
  10. 斯坦福大学机器学习相关网站——Andrew Ng