UVaLive 3708
题意:周长为10000的圆上等距分布n个雕塑,求再加入m个雕塑后,为使所有雕塑等距分布所需移动原来n个雕塑的最小总距离。
分析:计算相对距离。
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<algorithm>
#include<set>
#include<stack>
#include<list>
#include<map>
#include<queue>
#include<deque>
#include<vector>
#include<cctype>
using namespace std;
const int MAXN = + ;
const int MAXT = + ;
const int INF = 0x7f7f7f7f;
const double EPS = 1e-;
const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long llu;
int main()
{
int n, m;
while(scanf("%d%d", &n, &m) != EOF)
{
double ans = ;
for(int i = ; i < n; ++i)
{
double tmp = (double)i / n * (n + m);//所有待移动雕塑在n+m的等距分布里的坐标
ans += fabs(tmp - floor(tmp + 0.5)) / (n + m);//除以n+m,是使ans的结果是以总长度为1为基准,而不是n+m
}
printf("%.4lf\n", ans * );
}
return ;
}
UVaLive 3708的更多相关文章
- 思维 UVALive 3708 Graveyard
题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000 ...
- UVALive.3708 Graveyard (思维题)
UVALive.3708 Graveyard (思维题) 题意分析 这标题真悲伤,墓地. 在周长为1e4的圆周上等距分布着n个雕塑,现在要加入进来m个雕塑,最终还要使得这n+m个雕塑等距,那么原来的n ...
- uvalive 3708 Graveyard
https://vjudge.net/problem/UVALive-3708 题意: 一个长度为10000的圆环上放着n个雕塑,每个雕塑之间的距离均相等,即这个圆环被n个点均分.现在需要加入m个雕塑 ...
- UVAlive 3708 Graveyard(最优化问题)
题目描述: 在周长10000的圆上,初始等距的放置着n个雕塑,现在新加入m个雕塑,要使得这n+m个雕塑仍然等距,问原来n个雕塑要移动的距离总和的最小值. 原题地址: http://acm.hust.e ...
- UVALive 3708 Graveyard(思维题)
将原有的每个雕塑的坐标位置,映射在一个总长为n+m的数轴上,设第一个点的坐标为0,(新的等分点必然有至少有一个和原来n等分的等分点重合,因为等分点可以等距的绕圆周旋转,总可以转到有至少一个重合的,不妨 ...
- 2015Summer Training #2
暑假集训昨天刚开始,14级的小伙伴快到齐了,hhhhh ,毕竟下学期区域赛,对我们来说还是很困难的. 打算每天写份总结. UVA 11300 C.Spreading the Wealth 题目大意:n ...
- UVALive - 4108 SKYLINE[线段树]
UVALive - 4108 SKYLINE Time Limit: 3000MS 64bit IO Format: %lld & %llu Submit Status uDebug ...
- UVALive - 3942 Remember the Word[树状数组]
UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...
- UVALive - 3942 Remember the Word[Trie DP]
UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...
随机推荐
- URAL 1784 K - Rounders 找规律
K - RoundersTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view. ...
- Android Socket编程学习笔记
http://blog.csdn.net/eyu8874521/article/details/8847173 度娘给出的描述:通常也称作"套接字",用于描述IP地址和端口,是一个 ...
- 使用快盘托管Git库
Dropbox非常好用.可是我如今也没弄明确究竟哪里好用了.不如试试中国的金山快盘..起码不会操心被墙. cd ~/Kuaipan/repo git --bare init //初始化仓库 cd ~/ ...
- Nhibernate中 Many-To-One 中lazy="proxy" 延迟不起作用的原因
2010-07-15 12:10 by 彭白洋, 322 阅读, 0 评论, 收藏, 编辑 NHibernate中 Many-To-One 中lazy="proxy" 延迟不起作用 ...
- MySQL join buffer使用
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://huanghualiang.blog.51cto.com/6782683/12 ...
- slots - Python的结构体 转
上个月看了篇文章 “SAVING 9 GB OF RAM WITH PYTHON’S __SLOTS__”,原来Python也有类似结构体的东东.拖了一个月才写这篇,是因为太久没看pyth ...
- problem:SVN error: (501 Not Implemented)
problem:SVN error: (501 Not Implemented)solution:The repository was moved so the URL I was using is ...
- How to solve Original Tango programmer”Hardware not Found”?
Original Tango programmer is a new generation of transponder programmer which is developed to cover, ...
- Github 的一些基本操作
1.创建一个新的repository: 先在github上创建并写好相关名字,描述.例如这样一个地址: https://github.com/test/test2.git 回到本地目录如hellowo ...
- ios数据缓存方法
转载自:http://zhidao.baidu.com/link?url=jNTz6lkL1way8bJ-WPY197Pe9aEM_ql-MZbVJsM5tXr7Mv82W70QQ5a9UlvhMMS ...